1
0
mirror of https://github.com/mariadb-corporation/mariadb-columnstore-engine.git synced 2025-07-29 08:21:15 +03:00

Found and fixed a race on a counter in the new HJ hash table

construction code in PrimProc.
This commit is contained in:
Patrick LeBlanc
2019-12-17 18:17:04 -05:00
parent d8e763655c
commit 98d546c2c2
3 changed files with 26 additions and 8 deletions

View File

@ -36,6 +36,7 @@ PoolAllocator& PoolAllocator::operator=(const PoolAllocator& v)
{
allocSize = v.allocSize;
tmpSpace = v.tmpSpace;
useLock = v.useLock;
deallocateAll();
return *this;
}
@ -67,18 +68,28 @@ void PoolAllocator::newBlock()
void * PoolAllocator::allocOOB(uint64_t size)
{
bool _false = false;
OOBMemInfo memInfo;
if (useLock)
while (!lock.compare_exchange_weak(_false, true, std::memory_order_acquire))
_false = false;
memUsage += size;
memInfo.mem.reset(new uint8_t[size]);
memInfo.size = size;
void *ret = (void*) memInfo.mem.get();
oob[ret] = memInfo;
if (useLock)
lock.store(false, std::memory_order_release);
return ret;
}
void PoolAllocator::deallocate(void* p)
{
bool _false = false;
if (useLock)
while (!lock.compare_exchange_weak(_false, true, std::memory_order_acquire))
_false = false;
OutOfBandMap::iterator it = oob.find(p);
if (it == oob.end())
@ -86,6 +97,8 @@ void PoolAllocator::deallocate(void* p)
memUsage -= it->second.size;
oob.erase(it);
if (useLock)
lock.store(false, std::memory_order_release);
}
}