1
0
mirror of https://github.com/mariadb-corporation/mariadb-columnstore-engine.git synced 2025-07-27 21:01:50 +03:00

MCOL-5021 Add a new member function to the DBRM class, DBRM::addToLBIDList().

This function iterates over lbidList (populated by an earlier call to
DBRM::getUncommittedExtentLBIDs()) to find those LBIDs which belong to
the AUX column. It then finds the corresponding LBIDs for all other columns
which belong to the same table as the AUX LBID and appends them to lbidList.
The updated lbidList is used by invalidateUncommittedExtentLBIDs() to update
the casual partitioning information.

DBRM::addToLBIDList() only comes into play in case of a transaction ROLLBACK.
This commit is contained in:
Gagan Goel
2022-07-06 14:36:09 -04:00
parent 0818b95caa
commit 94e9f55940
5 changed files with 165 additions and 16 deletions

View File

@ -21,6 +21,7 @@
****************************************************************************/
#include <iostream>
#include <unordered_set>
#include <sys/types.h>
#include <vector>
#ifdef __linux__
@ -4453,6 +4454,97 @@ void DBRM::deleteAISequence(uint32_t OID)
}
}
void DBRM::addToLBIDList(uint32_t sessionID, vector<LBID_t>& lbidList)
{
boost::shared_ptr<execplan::CalpontSystemCatalog> systemCatalogPtr =
execplan::CalpontSystemCatalog::makeCalpontSystemCatalog(sessionID);
std::unordered_map<execplan::CalpontSystemCatalog::OID,
std::unordered_map<execplan::CalpontSystemCatalog::OID,
std::vector<struct BRM::EMEntry>>> extentMap;
int err = 0;
std::unordered_set<LBID_t> lbidSet;
std::unordered_set<execplan::CalpontSystemCatalog::OID> tableOidSet;
for (const auto i : lbidList)
{
lbidSet.insert(i);
execplan::CalpontSystemCatalog::OID oid;
uint16_t dbRoot, segmentNum;
uint32_t partitionNum, fbo;
err = lookupLocal(i, 0, false, oid, dbRoot, partitionNum, segmentNum, fbo);
if (err)
{
ostringstream os;
std::string errorMsg;
BRM::errString(err, errorMsg);
os << "lookupLocal from extent map error encountered while looking up lbid " << i
<< " and error code is " << err << " with message " << errorMsg;
throw runtime_error(os.str());
}
execplan::CalpontSystemCatalog::OID tableOid =
systemCatalogPtr->isAUXColumnOID(oid);
if (tableOid >= 3000)
{
if (tableOidSet.find(tableOid) == tableOidSet.end())
{
tableOidSet.insert(tableOid);
execplan::CalpontSystemCatalog::TableName tableName =
systemCatalogPtr->tableName(tableOid);
execplan::CalpontSystemCatalog::RIDList tableColRidList =
systemCatalogPtr->columnRIDs(tableName);
for (unsigned j = 0; j < tableColRidList.size(); j++)
{
auto objNum = tableColRidList[j].objnum;
err = getExtents(objNum, extentMap[tableOid][objNum]);
if (err)
{
ostringstream os;
os << "BRM lookup error. Could not get extents for OID " << objNum;
throw runtime_error(os.str());
}
}
}
uint32_t extentNumAux = fbo / (execplan::AUX_COL_WIDTH * 1024);
for (auto iter = extentMap[tableOid].begin(); iter != extentMap[tableOid].end(); iter++)
{
const std::vector<struct BRM::EMEntry>& extents = iter->second;
for (const struct BRM::EMEntry& extent : extents)
{
uint32_t extentNum = extent.blockOffset / (extent.range.size * 1024);
if (dbRoot == extent.dbRoot && partitionNum == extent.partitionNum &&
segmentNum == extent.segmentNum && extentNumAux == extentNum)
{
lbidSet.insert(extent.range.start);
break;
}
}
}
}
}
lbidList.clear();
for (auto iter = lbidSet.begin(); iter != lbidSet.end(); iter++)
{
lbidList.push_back(*iter);
}
// Sort the vector.
std::sort<vector<LBID_t>::iterator>(lbidList.begin(), lbidList.end());
}
void DBRM::invalidateUncommittedExtentLBIDs(execplan::CalpontSystemCatalog::SCN txnid, bool allExtents,
vector<LBID_t>* plbidList)
{
@ -4488,6 +4580,22 @@ void DBRM::invalidateUncommittedExtentLBIDs(execplan::CalpontSystemCatalog::SCN
if (plbidList == NULL)
{
getUncommittedExtentLBIDs(static_cast<VER_t>(txnid), localLBIDList);
try
{
addToLBIDList(0, localLBIDList);
}
catch (exception& e)
{
cerr << e.what() << endl;
return;
}
catch (...)
{
cerr << "invalidateUncommittedExtentLBIDs: caught an exception" << endl;
return;
}
plbidList = &localLBIDList;
}