Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DBBuilder: check syscat files instead dirs #3354

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion tools/dbbuilder/dbbuilder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
26 changes: 21 additions & 5 deletions writeengine/shared/we_fileop.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -496,7 +496,6 @@ bool FileOp::existsOIDDir(FID fid) const
{
return false;
}

return exists(fileName);
}

Expand Down Expand Up @@ -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());
}
}
Expand Down Expand Up @@ -2225,7 +2223,6 @@ int FileOp::oid2DirName(FID fid, char* oidDirName) const
return NO_ERROR;
}


if (oidDirName == nullptr)
{
return ERR_INTERNAL;
Expand All @@ -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<std::string> 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
Expand Down Expand Up @@ -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;
Expand Down
7 changes: 6 additions & 1 deletion writeengine/shared/we_fileop.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
#include <map>
#include <boost/thread.hpp>


#include "we_blockop.h"
#include "we_brm.h"
#include "we_config.h"
Expand Down Expand Up @@ -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
*
Expand Down