1
0
mirror of https://github.com/mariadb-corporation/mariadb-columnstore-engine.git synced 2025-07-30 19:23:07 +03:00

MCOL-744 Fix BPP mutex crash

Whilst very rare we can hit a case where we attempt to unlock objLock
when it is already unlocked. With the Boost version in Ubuntu 16.04 this
triggers an abort() effectively crashing PrimProc.

In this patch we switch to a pthread mutex instead which does not have
this limitation. At a later date we can look into refactoring how BPP
and this mutex works.
This commit is contained in:
Andrew Hutchings
2017-08-11 07:17:07 +01:00
parent 76fb89c13f
commit fa17a98d60
2 changed files with 19 additions and 16 deletions

View File

@ -112,6 +112,7 @@ BatchPrimitiveProcessor::BatchPrimitiveProcessor() :
{
pp.setLogicalBlockMode(true);
pp.setBlockPtr((int *) blockData);
pthread_mutex_init(&objLock,NULL);
}
BatchPrimitiveProcessor::BatchPrimitiveProcessor(ByteStream &b, double prefetch,
@ -153,6 +154,7 @@ BatchPrimitiveProcessor::BatchPrimitiveProcessor(ByteStream &b, double prefetch,
pp.setLogicalBlockMode(true);
pp.setBlockPtr((int *) blockData);
sendThread = bppst;
pthread_mutex_init(&objLock, NULL);
initBPP(b);
// cerr << "made a BPP\n";
}
@ -175,6 +177,7 @@ BatchPrimitiveProcessor::~BatchPrimitiveProcessor()
counterLock.lock();
}
counterLock.unlock();
pthread_mutex_destroy(&objLock);
}
/**
@ -233,7 +236,7 @@ void BatchPrimitiveProcessor::initBPP(ByteStream &bs)
}
if (doJoin) {
objLock.lock();
pthread_mutex_lock(&objLock);
if (ot == ROW_GROUP) {
bs >> joinerCount;
// cout << "joinerCount = " << joinerCount << endl;
@ -325,7 +328,7 @@ void BatchPrimitiveProcessor::initBPP(ByteStream &bs)
joiner.reset(new Joiner((bool) tmp8));
}
#ifdef __FreeBSD__
objLock.unlock();
pthread_mutex_unlock(&objLock);
#endif
}
@ -401,7 +404,7 @@ void BatchPrimitiveProcessor::resetBPP(ByteStream &bs, const SP_UM_MUTEX& w,
uint32_t i;
vector<uint64_t> preloads;
objLock.lock();
pthread_mutex_lock(&objLock);
writelock = w;
sock = s;
@ -452,7 +455,7 @@ void BatchPrimitiveProcessor::resetBPP(ByteStream &bs, const SP_UM_MUTEX& w,
buildVSSCache(count);
#ifdef __FreeBSD__
objLock.unlock();
pthread_mutex_unlock(&objLock);
#endif
}
@ -599,7 +602,7 @@ int BatchPrimitiveProcessor::endOfJoiner()
#endif
#ifndef __FreeBSD__
objLock.unlock();
pthread_mutex_unlock(&objLock);
#endif
return 0;
}
@ -1486,7 +1489,7 @@ void BatchPrimitiveProcessor::execute()
#endif
#ifndef __FreeBSD__
objLock.unlock();
pthread_mutex_unlock(&objLock);
#endif
throw n; // need to pass this through to BPPSeeder
}
@ -1777,12 +1780,7 @@ int BatchPrimitiveProcessor::operator()()
vssCache.clear();
#ifndef __FreeBSD__
// If we've been aborted the lock *may* have been released already
// By doing try_lock, we ensure the unlock will work whether it was
// locked or not.
if (sendThread->aborted())
objLock.try_lock();
objLock.unlock();
pthread_mutex_unlock(&objLock);
#endif
freeLargeBuffers();
#ifdef PRIMPROC_STOPWATCH
@ -1881,7 +1879,7 @@ SBPP BatchPrimitiveProcessor::duplicate()
}
bpp->doJoin = doJoin;
if (doJoin) {
bpp->objLock.lock();
pthread_mutex_lock(&bpp->objLock);
bpp->joinerSize = joinerSize;
if (ot == ROW_GROUP) {
/* There are add'l join vars, but only these are necessary for processing
@ -1921,7 +1919,7 @@ SBPP BatchPrimitiveProcessor::duplicate()
else
bpp->joiner = joiner;
#ifdef __FreeBSD__
bpp->objLock.unlock();
pthread_mutex_unlock(&bpp->objLock);
#endif
}