From 80277a5e7daab01054c4dbb50fb637ad6ec5f849 Mon Sep 17 00:00:00 2001 From: Denis Khalikov Date: Mon, 25 Nov 2024 16:02:37 +0000 Subject: [PATCH] DBBuilder: check syscat files instead dirs --- tools/dbbuilder/dbbuilder.cpp | 2 +- writeengine/shared/we_fileop.cpp | 26 +++++++++++++++++++++----- writeengine/shared/we_fileop.h | 7 ++++++- 3 files changed, 28 insertions(+), 7 deletions(-) diff --git a/tools/dbbuilder/dbbuilder.cpp b/tools/dbbuilder/dbbuilder.cpp index 9958d2eef..b5bb02efd 100644 --- a/tools/dbbuilder/dbbuilder.cpp +++ b/tools/dbbuilder/dbbuilder.cpp @@ -68,7 +68,7 @@ int checkNotThere(WriteEngine::FID fid) { WriteEngine::FileOp fileOp; - return (fileOp.existsOIDDir(fid) ? -1 : 0); + return (fileOp.existsDefaultFile(fid) ? -1 : 0); } void usage() diff --git a/writeengine/shared/we_fileop.cpp b/writeengine/shared/we_fileop.cpp index da725ff03..dbf7f861c 100644 --- a/writeengine/shared/we_fileop.cpp +++ b/writeengine/shared/we_fileop.cpp @@ -496,7 +496,6 @@ bool FileOp::existsOIDDir(FID fid) const { return false; } - return exists(fileName); } @@ -1809,8 +1808,7 @@ void FileOp::initDbRootExtentMutexes() for (size_t i = 0; i < rootIds.size(); i++) { - m_DbRootAddExtentMutexes.emplace(std::piecewise_construct, - std::forward_as_tuple(rootIds[i]), + m_DbRootAddExtentMutexes.emplace(std::piecewise_construct, std::forward_as_tuple(rootIds[i]), std::forward_as_tuple()); } } @@ -2225,7 +2223,6 @@ int FileOp::oid2DirName(FID fid, char* oidDirName) const return NO_ERROR; } - if (oidDirName == nullptr) { return ERR_INTERNAL; @@ -2250,6 +2247,26 @@ int FileOp::oid2DirName(FID fid, char* oidDirName) const return ERR_FILE_NOT_EXIST; } +bool FileOp::existsDefaultFile(FID fid) const +{ + char dbDir[MAX_DB_DIR_LEVEL][MAX_DB_DIR_NAME_SIZE]; + char fileName[FILE_NAME_SIZE]; + + RETURN_ON_ERROR((Convertor::oid2FileName(fid, fileName, dbDir, 0, 0))); + std::vector dbRootPathList; + Config::getDBRootPathList(dbRootPathList); + + for (unsigned i = 0; i < dbRootPathList.size(); i++) + { + std::stringstream stream; + stream << dbRootPathList[i].c_str() << "/" << fileName; + string fullFileName = stream.str(); + if (IDBPolicy::exists(fullFileName.c_str())) + return true; + } + + return false; +} /*********************************************************** * DESCRIPTION: * Construct directory path for the specified fid (OID), DBRoot, and @@ -2555,7 +2572,6 @@ bool FileOp::isDiskSpaceAvail(const std::string& fileName, int nBlocks) const //"; pctUsed: " << (((totalBlocks-freeBlocks)/totalBlocks)*100.0) << //"; bAvail: " << bSpaceAvail << std::endl; } - } return bSpaceAvail; diff --git a/writeengine/shared/we_fileop.h b/writeengine/shared/we_fileop.h index e93d15897..98141bb31 100644 --- a/writeengine/shared/we_fileop.h +++ b/writeengine/shared/we_fileop.h @@ -27,7 +27,6 @@ #include #include - #include "we_blockop.h" #include "we_brm.h" #include "we_config.h" @@ -130,6 +129,12 @@ class FileOp : public BlockOp, public WeUIDGID */ EXPORT bool existsOIDDir(FID fid) const; + /** + * @brief Check whether a column file exists by the given `fid` in all + * available db roots and default values for `partition` and `segment`. + */ + EXPORT bool existsDefaultFile(FID fid) const; + /** * @brief Expand current abbreviated extent for this column to a full extent *