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

fix(extent-map): MCOL-5559 This patch extends the scope of the crit section to cover remap operation to avoid access races running EMIndex operations

This commit is contained in:
Roman Nozdrin
2023-08-22 08:36:37 +00:00
parent 74647cd90c
commit 7e746ad90c
2 changed files with 45 additions and 9 deletions

View File

@ -2080,20 +2080,54 @@ void ExtentMap::grabEMIndex(OPS op)
}
else
{
// Sending down current Managed Shmem size. If EMIndexImpl instance size doesn't match
// fEMIndexShminfo->allocdSize makeExtentMapIndexImpl will remap managed shmem segment.
fPExtMapIndexImpl_ =
ExtentMapIndexImpl::makeExtentMapIndexImpl(getInitialEMIndexShmkey(), fEMIndexShminfo->allocdSize);
if (op == READ)
{
fMST.getTable_upgrade(MasterSegmentTable::EMIndex);
emIndexLocked = true;
if (r_only)
fPExtMapIndexImpl_->makeReadOnly();
// Sending down current Managed Shmem size. If EMIndexImpl instance size doesn't match
// fEMIndexShminfo->allocdSize makeExtentMapIndexImpl will remap managed shmem segment.
fPExtMapIndexImpl_ = ExtentMapIndexImpl::makeExtentMapIndexImpl(getInitialEMIndexShmkey(),
fEMIndexShminfo->allocdSize);
if (r_only)
fPExtMapIndexImpl_->makeReadOnly();
emIndexLocked = false;
fMST.getTable_downgrade(MasterSegmentTable::EMIndex);
}
else
{
fPExtMapIndexImpl_ = ExtentMapIndexImpl::makeExtentMapIndexImpl(getInitialEMIndexShmkey(),
fEMIndexShminfo->allocdSize);
if (r_only)
fPExtMapIndexImpl_->makeReadOnly();
}
}
}
else if (fPExtMapIndexImpl_->getShmemImplSize() != (unsigned)fEMIndexShminfo->allocdSize)
{
fPExtMapIndexImpl_->refreshShm();
fPExtMapIndexImpl_ =
ExtentMapIndexImpl::makeExtentMapIndexImpl(getInitialEMIndexShmkey(), fEMIndexShminfo->allocdSize);
if (op == READ)
{
fMST.getTable_upgrade(MasterSegmentTable::EMIndex);
emIndexLocked = true;
fPExtMapIndexImpl_->refreshShm();
fPExtMapIndexImpl_ =
ExtentMapIndexImpl::makeExtentMapIndexImpl(getInitialEMIndexShmkey(), fEMIndexShminfo->allocdSize);
emIndexLocked = false;
fMST.getTable_downgrade(MasterSegmentTable::EMIndex);
}
else
{
fPExtMapIndexImpl_->refreshShm();
fPExtMapIndexImpl_ =
ExtentMapIndexImpl::makeExtentMapIndexImpl(getInitialEMIndexShmkey(), fEMIndexShminfo->allocdSize);
}
}
}

View File

@ -372,6 +372,8 @@ class ExtentMapIndexImpl
{
if (fInstance_)
{
// effectively umpas a mapped managed shmem segment changing the segment VA address
// when mapped next time.
delete fInstance_;
fInstance_ = nullptr;
}