From ee682b834f01d6ae01ccba14d777cecbb5cebb5e Mon Sep 17 00:00:00 2001 From: Patrick LeBlanc Date: Fri, 13 Mar 2020 14:50:21 -0400 Subject: [PATCH] MCOL-3251. Bad file-not-found error msg from PrimProc Wrote a different method for PrimProc to use to get filenames. --- primitives/blockcache/iomanager.cpp | 55 +++++++++++++++++++++++++++-- primitives/blockcache/iomanager.h | 7 +++- 2 files changed, 59 insertions(+), 3 deletions(-) diff --git a/primitives/blockcache/iomanager.cpp b/primitives/blockcache/iomanager.cpp index 097f3cad6..92b3fb28f 100644 --- a/primitives/blockcache/iomanager.cpp +++ b/primitives/blockcache/iomanager.cpp @@ -1356,18 +1356,69 @@ ioManager::ioManager(FileBufferMgr& fbm, } fThreadCount = thrCount; + lastConfigMTime = 0; + loadDBRootCache(); go(); } -void ioManager::buildOidFileName(const BRM::OID_t oid, const uint16_t dbRoot, const uint16_t partNum, const uint32_t segNum, char* file_name) +void ioManager::loadDBRootCache() { + if (fConfig->getLastMTime() == lastConfigMTime) + return; + + char buf[100]; + dbRootCache.clear(); + + // this will grab all of the dbroots on the cluster, not just the ones on this node + // for simplicity. + oam::Oam OAM; + oam::DBRootConfigList dbRoots; + OAM.getSystemDbrootConfig(dbRoots); + for (auto _dbroot : dbRoots) + { + sprintf(buf, "DBRoot%d", _dbroot); + string location = fConfig->getConfig("SystemConfig", buf); + dbRootCache[_dbroot] = location; + } +} + +void ioManager::buildOidFileName(const BRM::OID_t oid, uint16_t dbRoot, const uint16_t partNum, const uint32_t segNum, char* file_name) +{ + // when it's a request for the version buffer, the dbroot comes in as 0 for legacy reasons + if (dbRoot == 0 && oid < 1000) + dbRoot = fdbrm.getDBRootOfVBOID(oid); + + boost::unique_lock lock(dbRootCacheLock); + loadDBRootCache(); + string dbRootPath; + auto it = dbRootCache.find(dbRoot); + if (it == dbRootCache.end()) + { + ostringstream oss; + oss << "(dbroot " << dbRoot << " offline)"; + dbRootPath = oss.str(); + } + else + dbRootPath = it->second; + lock.unlock(); + + // different filenames for the version buffer files + if (oid < 1000) + snprintf(file_name, WriteEngine::FILE_NAME_SIZE, "%s/versionbuffer.cdf", dbRootPath.c_str()); + else + snprintf(file_name, WriteEngine::FILE_NAME_SIZE, "%s/%03u.dir/%03u.dir/%03u.dir/%03u.dir/%03u.dir/FILE%03d.cdf", + dbRootPath.c_str(), oid >> 24, (oid & 0x00ff0000) >> 16, (oid & 0x0000ff00) >> 8, + oid & 0x000000ff, partNum, segNum); + + + /* old version if (fFileOp.getFileName(oid, file_name, dbRoot, partNum, segNum) != WriteEngine::NO_ERROR) { file_name[0] = 0; throw std::runtime_error("fileOp.getFileName failed"); } - //cout << "Oid2Filename o: " << oid << " n: " << file_name << endl; + */ } const int ioManager::localLbidLookup(BRM::LBID_t lbid, diff --git a/primitives/blockcache/iomanager.h b/primitives/blockcache/iomanager.h index 4ac14a9b0..ad09fd0db 100644 --- a/primitives/blockcache/iomanager.h +++ b/primitives/blockcache/iomanager.h @@ -83,7 +83,7 @@ public: uint32_t& fileBlockOffset); void buildOidFileName(const BRM::OID_t oid, - const uint16_t dbRoot, + uint16_t dbRoot, const uint16_t partNum, const uint32_t segNum, char* file_name); @@ -153,6 +153,11 @@ private: uint32_t fDecreaseOpenFilesCount; bool fFDCacheTrace; std::ofstream fFDTraceFile; + + std::map dbRootCache; + boost::mutex dbRootCacheLock; + void loadDBRootCache(); + time_t lastConfigMTime; };