You've already forked mariadb-columnstore-engine
mirror of
https://github.com/mariadb-corporation/mariadb-columnstore-engine.git
synced 2025-08-05 16:15:50 +03:00
MCOL-371 fix mutex free crash
It is possible for an exception to be thrown when a memory limit is hit whilst a mutex is lock. That mutex is never unlocked and in Ubuntu 16.04 release build it can cause a crash when freed. This patch catches the exception, releases the lock and then re-throws.
This commit is contained in:
@@ -347,11 +347,19 @@ void TupleAggregateStep::doThreadedSecondPhaseAggregate(uint32_t threadID)
|
|||||||
for (uint32_t c = 0; c < fNumOfBuckets && !cancelled(); c++)
|
for (uint32_t c = 0; c < fNumOfBuckets && !cancelled(); c++)
|
||||||
{
|
{
|
||||||
if (!bucketDone[c] && fAgg_mutex[c]->try_lock())
|
if (!bucketDone[c] && fAgg_mutex[c]->try_lock())
|
||||||
|
{
|
||||||
|
try
|
||||||
{
|
{
|
||||||
if (multiDist)
|
if (multiDist)
|
||||||
dynamic_cast<RowAggregationMultiDistinct*>(fAggregators[c].get())->doDistinctAggregation_rowVec(rowBucketVecs[c]);
|
dynamic_cast<RowAggregationMultiDistinct*>(fAggregators[c].get())->doDistinctAggregation_rowVec(rowBucketVecs[c]);
|
||||||
else
|
else
|
||||||
dynamic_cast<RowAggregationDistinct*>(fAggregators[c].get())->doDistinctAggregation_rowVec(rowBucketVecs[c][0]);
|
dynamic_cast<RowAggregationDistinct*>(fAggregators[c].get())->doDistinctAggregation_rowVec(rowBucketVecs[c][0]);
|
||||||
|
}
|
||||||
|
catch(...)
|
||||||
|
{
|
||||||
|
fAgg_mutex[c]->unlock();
|
||||||
|
throw;
|
||||||
|
}
|
||||||
fAgg_mutex[c]->unlock();
|
fAgg_mutex[c]->unlock();
|
||||||
bucketDone[c] = true;
|
bucketDone[c] = true;
|
||||||
rowBucketVecs[c][0].clear();
|
rowBucketVecs[c][0].clear();
|
||||||
@@ -4300,12 +4308,20 @@ void TupleAggregateStep::threadedAggregateRowGroups(uint32_t threadID)
|
|||||||
for (uint32_t c = 0; c < fNumOfBuckets && !cancelled(); c++)
|
for (uint32_t c = 0; c < fNumOfBuckets && !cancelled(); c++)
|
||||||
{
|
{
|
||||||
if (!fEndOfResult && !bucketDone[c] && fAgg_mutex[c]->try_lock())
|
if (!fEndOfResult && !bucketDone[c] && fAgg_mutex[c]->try_lock())
|
||||||
|
{
|
||||||
|
try
|
||||||
{
|
{
|
||||||
didWork = true;
|
didWork = true;
|
||||||
if (multiDist)
|
if (multiDist)
|
||||||
dynamic_cast<RowAggregationMultiDistinct*>(fAggregators[c].get())->addRowGroup(&fRowGroupIns[threadID], rowBucketVecs[c]);
|
dynamic_cast<RowAggregationMultiDistinct*>(fAggregators[c].get())->addRowGroup(&fRowGroupIns[threadID], rowBucketVecs[c]);
|
||||||
else
|
else
|
||||||
fAggregators[c]->addRowGroup(&fRowGroupIns[threadID], rowBucketVecs[c][0]);
|
fAggregators[c]->addRowGroup(&fRowGroupIns[threadID], rowBucketVecs[c][0]);
|
||||||
|
}
|
||||||
|
catch(...)
|
||||||
|
{
|
||||||
|
fAgg_mutex[c]->unlock();
|
||||||
|
throw;
|
||||||
|
}
|
||||||
fAgg_mutex[c]->unlock();
|
fAgg_mutex[c]->unlock();
|
||||||
rowBucketVecs[c][0].clear();
|
rowBucketVecs[c][0].clear();
|
||||||
bucketDone[c] = true;
|
bucketDone[c] = true;
|
||||||
|
Reference in New Issue
Block a user