mirror of https://gitee.com/bigwinds/arangodb
fix a rare recovery error, add diagnostic output (#8931)
This commit is contained in:
parent
1ae5f8daec
commit
445d020bac
|
@ -1195,6 +1195,9 @@ MMFilesDatafile* MMFilesCollection::createDatafile(TRI_voc_fid_t fid, uint32_t j
|
||||||
std::string oldName = datafile->getName();
|
std::string oldName = datafile->getName();
|
||||||
std::string jname("journal-" + std::to_string(datafile->fid()) + ".db");
|
std::string jname("journal-" + std::to_string(datafile->fid()) + ".db");
|
||||||
std::string filename = arangodb::basics::FileUtils::buildFilename(path(), jname);
|
std::string filename = arangodb::basics::FileUtils::buildFilename(path(), jname);
|
||||||
|
|
||||||
|
LOG_TOPIC("3e87e", TRACE, arangodb::Logger::DATAFILES)
|
||||||
|
<< "renaming journal '" << datafile->getName() << "' to '" << filename << "'";
|
||||||
|
|
||||||
int res = datafile->rename(filename);
|
int res = datafile->rename(filename);
|
||||||
|
|
||||||
|
|
|
@ -345,6 +345,11 @@ MMFilesRenameDatafileDitch* MMFilesDitches::createMMFilesRenameDatafileDitch(
|
||||||
try {
|
try {
|
||||||
auto ditch = new MMFilesRenameDatafileDitch(this, datafile, compactor, collection,
|
auto ditch = new MMFilesRenameDatafileDitch(this, datafile, compactor, collection,
|
||||||
callback, filename, line);
|
callback, filename, line);
|
||||||
|
TRI_IF_FAILURE("no-rename-datafile") {
|
||||||
|
// exit prematurely
|
||||||
|
return ditch;
|
||||||
|
}
|
||||||
|
|
||||||
link(ditch);
|
link(ditch);
|
||||||
|
|
||||||
return ditch;
|
return ditch;
|
||||||
|
|
|
@ -2761,7 +2761,7 @@ int MMFilesEngine::openCollection(TRI_vocbase_t* vocbase,
|
||||||
|
|
||||||
for (auto const& file : files) {
|
for (auto const& file : files) {
|
||||||
std::vector<std::string> parts = StringUtils::split(file, '.');
|
std::vector<std::string> parts = StringUtils::split(file, '.');
|
||||||
|
|
||||||
if (parts.size() < 2 || parts.size() > 3 || parts[0].empty()) {
|
if (parts.size() < 2 || parts.size() > 3 || parts[0].empty()) {
|
||||||
LOG_TOPIC("9c40b", TRACE, Logger::DATAFILES)
|
LOG_TOPIC("9c40b", TRACE, Logger::DATAFILES)
|
||||||
<< "ignoring file '" << file << "' because it does not look like a datafile";
|
<< "ignoring file '" << file << "' because it does not look like a datafile";
|
||||||
|
@ -2783,6 +2783,9 @@ int MMFilesEngine::openCollection(TRI_vocbase_t* vocbase,
|
||||||
std::string filetype = next[0];
|
std::string filetype = next[0];
|
||||||
next.erase(next.begin());
|
next.erase(next.begin());
|
||||||
std::string qualifier = StringUtils::join(next, '-');
|
std::string qualifier = StringUtils::join(next, '-');
|
||||||
|
|
||||||
|
LOG_TOPIC("1b99a", TRACE, Logger::DATAFILES)
|
||||||
|
<< "found file '" << file << "', filetype: " << filetype << ", size: " << TRI_SizeFile(filename.c_str());
|
||||||
|
|
||||||
// .............................................................................
|
// .............................................................................
|
||||||
// file is dead
|
// file is dead
|
||||||
|
@ -2812,10 +2815,13 @@ int MMFilesEngine::openCollection(TRI_vocbase_t* vocbase,
|
||||||
|
|
||||||
// found a compaction file. now rename it back
|
// found a compaction file. now rename it back
|
||||||
if (filetype == "compaction") {
|
if (filetype == "compaction") {
|
||||||
std::string relName = "datafile-" + qualifier + "." + extension;
|
std::string relNameDatafile = "datafile-" + qualifier + "." + extension;
|
||||||
std::string newName = FileUtils::buildFilename(physical->path(), relName);
|
std::string newName = FileUtils::buildFilename(physical->path(), relNameDatafile);
|
||||||
|
|
||||||
|
std::string relNameJournal = "journal-" + qualifier + "." + extension;
|
||||||
|
std::string nameJournal = FileUtils::buildFilename(physical->path(), relNameJournal);
|
||||||
|
|
||||||
if (FileUtils::exists(newName)) {
|
if (FileUtils::exists(newName) || FileUtils::exists(nameJournal)) {
|
||||||
// we have a compaction-xxxx and a datafile-xxxx file. we'll keep
|
// we have a compaction-xxxx and a datafile-xxxx file. we'll keep
|
||||||
// the datafile
|
// the datafile
|
||||||
FileUtils::remove(filename);
|
FileUtils::remove(filename);
|
||||||
|
|
Loading…
Reference in New Issue