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

MCOL-834 Fix crashes introduced

* Fix race condition in cleanup
* Fix mutex cleanup crash
This commit is contained in:
Andrew Hutchings
2017-07-27 23:22:45 +01:00
parent fd018011a7
commit bc80fd99dc
3 changed files with 13 additions and 6 deletions

View File

@ -1765,6 +1765,8 @@ int BatchPrimitiveProcessor::operator()()
vssCache.clear(); vssCache.clear();
#ifndef __FreeBSD__ #ifndef __FreeBSD__
if (sendThread->aborted())
objLock.try_lock();
objLock.unlock(); objLock.unlock();
#endif #endif
freeLargeBuffers(); freeLargeBuffers();

View File

@ -121,7 +121,7 @@ class BatchPrimitiveProcessor
// these two functions are used by BPPV to create BPP instances // these two functions are used by BPPV to create BPP instances
// on demand. TRY not to use unlock() for anything else. // on demand. TRY not to use unlock() for anything else.
void unlock() { objLock.unlock(); } void unlock() { objLock.try_lock(); objLock.unlock(); }
bool hasJoin() { return doJoin; } bool hasJoin() { return doJoin; }
private: private:
BatchPrimitiveProcessor(); BatchPrimitiveProcessor();

View File

@ -32,6 +32,7 @@
#include <cassert> #include <cassert>
#include <boost/thread.hpp> #include <boost/thread.hpp>
#include <boost/thread/condition.hpp> #include <boost/thread/condition.hpp>
#include <boost/foreach.hpp>
#ifdef _MSC_VER #ifdef _MSC_VER
#include <unordered_map> #include <unordered_map>
typedef int pthread_t; typedef int pthread_t;
@ -1152,21 +1153,21 @@ struct BPPHandler
~BPPHandler() ~BPPHandler()
{ {
mutex::scoped_lock scoped(bppLock);
for (bppKeysIt = bppKeys.begin() ; bppKeysIt != bppKeys.end(); ++bppKeysIt) for (bppKeysIt = bppKeys.begin() ; bppKeysIt != bppKeys.end(); ++bppKeysIt)
{ {
uint32_t key = *bppKeysIt; uint32_t key = *bppKeysIt;
BPPMap::iterator it; BPPMap::iterator it;
mutex::scoped_lock scoped(bppLock);
it = bppMap.find(key); it = bppMap.find(key);
if (it != bppMap.end()) { if (it != bppMap.end()) {
it->second->abort(); it->second->abort();
bppMap.erase(it); bppMap.erase(it);
} }
scoped.unlock();
fPrimitiveServerPtr->getProcessorThreadPool()->removeJobs(key); fPrimitiveServerPtr->getProcessorThreadPool()->removeJobs(key);
OOBPool->removeJobs(key); OOBPool->removeJobs(key);
} }
scoped.unlock();
} }
struct BPPHandlerFunctor : public PriorityThreadPool::Functor { struct BPPHandlerFunctor : public PriorityThreadPool::Functor {
@ -1224,11 +1225,11 @@ struct BPPHandler
bs.advance(sizeof(ISMPacketHeader)); bs.advance(sizeof(ISMPacketHeader));
bs >> key; bs >> key;
mutex::scoped_lock scoped(bppLock);
bppKeysIt = std::find(bppKeys.begin(), bppKeys.end(), key); bppKeysIt = std::find(bppKeys.begin(), bppKeys.end(), key);
if (bppKeysIt != bppKeys.end()) { if (bppKeysIt != bppKeys.end()) {
bppKeys.erase(bppKeysIt); bppKeys.erase(bppKeysIt);
} }
mutex::scoped_lock scoped(bppLock);
it = bppMap.find(key); it = bppMap.find(key);
if (it != bppMap.end()) { if (it != bppMap.end()) {
it->second->abort(); it->second->abort();
@ -1300,9 +1301,9 @@ struct BPPHandler
bppv->add(dup); bppv->add(dup);
} }
} }
key = bpp->getUniqueID(); mutex::scoped_lock scoped(bppLock);
key = bpp->getUniqueID();
bppKeys.push_back(key); bppKeys.push_back(key);
mutex::scoped_lock scoped(bppLock);
bool newInsert; bool newInsert;
newInsert = bppMap.insert(pair<uint32_t, SBPPV>(key, bppv)).second; newInsert = bppMap.insert(pair<uint32_t, SBPPV>(key, bppv)).second;
//cout << "creating BPP # " << key << endl; //cout << "creating BPP # " << key << endl;
@ -2210,6 +2211,10 @@ boost::shared_ptr<BatchPrimitiveProcessor> BPPV::next()
void BPPV::abort() void BPPV::abort()
{ {
sendThread->abort(); sendThread->abort();
BOOST_FOREACH( boost::shared_ptr<BatchPrimitiveProcessor> bpp, v )
{
bpp->unlock();
}
} }
bool BPPV::aborted() bool BPPV::aborted()