diff --git a/dbcon/mysql/is_columnstore_files.cpp b/dbcon/mysql/is_columnstore_files.cpp index 11f64e1d2..060f9d280 100644 --- a/dbcon/mysql/is_columnstore_files.cpp +++ b/dbcon/mysql/is_columnstore_files.cpp @@ -33,6 +33,7 @@ #include "we_brm.h" #include "bytestream.h" #include "liboamcpp.h" +#include "oamcache.h" #include "messagequeue.h" #include "messagequeuepool.h" #include "we_messages.h" @@ -119,7 +120,7 @@ static int generate_result(BRM::OID_t oid, BRM::DBRM* emp, TABLE* table, THD* th off_t compressedFileSize = 0; we_config.initConfigCache(); messageqcpp::MessageQueueClient* msgQueueClient; - oam::Oam oam_instance; + oam::OamCache* oamcache = oam::OamCache::makeOamCache(); int pmId = 0; int rc; @@ -141,7 +142,7 @@ static int generate_result(BRM::OID_t oid, BRM::DBRM* emp, TABLE* table, THD* th try { - oam_instance.getDbrootPmConfig(iter->dbRoot, pmId); + pmId = oamcache->getOwnerPM(iter->dbRoot); } catch (std::runtime_error&) { diff --git a/dmlproc/dmlproc.cpp b/dmlproc/dmlproc.cpp index 204bb15e3..565a8b35b 100644 --- a/dmlproc/dmlproc.cpp +++ b/dmlproc/dmlproc.cpp @@ -393,7 +393,7 @@ void rollbackAll(DBRM* dbrm) try { - rollbackProcessor.processBulkRollback(tableLocks[i], dbrm, uniqueId, dbRootPMMap, lockReleased); + rollbackProcessor.processBulkRollback(tableLocks[i], dbrm, uniqueId, oamcache, lockReleased); ostringstream oss; oss << "DMLProc started bulkrollback on table OID " << tableLocks[i].tableOID << " and table lock id " << tableLocks[i].id << " finished and tablelock is released."; diff --git a/dmlproc/dmlprocessor.cpp b/dmlproc/dmlprocessor.cpp index 46949dbfb..5bc60ad9a 100644 --- a/dmlproc/dmlprocessor.cpp +++ b/dmlproc/dmlprocessor.cpp @@ -1847,7 +1847,7 @@ void DMLProcessor::operator()() void RollbackTransactionProcessor::processBulkRollback(BRM::TableLockInfo lockInfo, BRM::DBRM* dbrm, uint64_t uniqueId, - OamCache::dbRootPMMap_t& dbRootPMMap, + OamCache* oamcache, bool& lockReleased) { // Take over ownership of stale lock. @@ -1886,7 +1886,7 @@ void RollbackTransactionProcessor::processBulkRollback(BRM::TableLockInfo lockIn for (uint32_t i = 0; i < lockInfo.dbrootList.size(); i++) { - pmId = (*dbRootPMMap)[lockInfo.dbrootList[i]]; + pmId = oamcache->getOwnerPM(lockInfo.dbrootList[i]); pmSet.insert(pmId); } diff --git a/dmlproc/dmlprocessor.h b/dmlproc/dmlprocessor.h index 3492bcfa5..6d020770b 100644 --- a/dmlproc/dmlprocessor.h +++ b/dmlproc/dmlprocessor.h @@ -321,7 +321,7 @@ class RollbackTransactionProcessor : public dmlpackageprocessor::DMLPackageProce } void processBulkRollback(BRM::TableLockInfo lockInfo, BRM::DBRM* dbrm, uint64_t uniqueId, - oam::OamCache::dbRootPMMap_t& dbRootPMMap, bool& lockReleased); + oam::OamCache* oamcache, bool& lockReleased); protected: private: diff --git a/oam/oamcpp/oamcache.cpp b/oam/oamcpp/oamcache.cpp index 5f336c14c..15f50401d 100644 --- a/oam/oamcpp/oamcache.cpp +++ b/oam/oamcpp/oamcache.cpp @@ -295,5 +295,17 @@ int OamCache::getOwnerPM(int dbroot) // Owner's PM index. } idbassert_s(0, "cannot find owner for dbroot " << dbroot); } +std::vector OamCache::getPMDBRoots(int PM) // what DBRoots are owned by given PM. +{ + std::vector result; + for (const auto& dbroot : (*dbRootPMMap)) + { + if (dbroot.second.find(PM) != dbroot.second.end()) + { + result.push_back(dbroot.first); + } + } + return result; +} } /* namespace oam */ diff --git a/tools/cleartablelock/cleartablelock.cpp b/tools/cleartablelock/cleartablelock.cpp index 361d354a6..5620bbb56 100644 --- a/tools/cleartablelock/cleartablelock.cpp +++ b/tools/cleartablelock/cleartablelock.cpp @@ -159,19 +159,22 @@ int constructPMList(const std::vector& dbRootList, std::vector pmSet; // used to filter out duplicates - int pm; + std::set pms; for (unsigned j = 0; j < dbRootList.size(); j++) { dbRoot = dbRootList[j]; - oam.getDbrootPmConfig(dbRootList[j], pm); - pmSet.insert(pm); + oam.getDbrootPmConfig(dbRootList[j], pms); + for (auto pm : pms) + { + pmSet.insert(pm); + } } // Store unique set of PM IDs into output vector - for (std::set::const_iterator iter = pmSet.begin(); iter != pmSet.end(); ++iter) + for (auto pm : pmSet) { - pmList.push_back(*iter); + pmList.push_back(pm); } } catch (std::exception& ex)