From 598a093f69273a7ecb71fff894ad22fd64b4293d Mon Sep 17 00:00:00 2001 From: Igor Solodovnikov Date: Fri, 12 Feb 2021 19:15:52 +0200 Subject: [PATCH 1/3] PSMDB-810 explicitly close destination file to avoid error swallowing --- src/mongo/db/storage/wiredtiger/wiredtiger_kv_engine.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/mongo/db/storage/wiredtiger/wiredtiger_kv_engine.cpp b/src/mongo/db/storage/wiredtiger/wiredtiger_kv_engine.cpp index 30f6c2fe450e7..3300acf71b702 100644 --- a/src/mongo/db/storage/wiredtiger/wiredtiger_kv_engine.cpp +++ b/src/mongo/db/storage/wiredtiger/wiredtiger_kv_engine.cpp @@ -1491,6 +1491,8 @@ static void copy_file_size(const boost::filesystem::path& srcFile, const boost:: dst.write(bufptr, cnt); fsize -= cnt; } + + dst.close(); } Status WiredTigerKVEngine::_hotBackupPopulateLists(OperationContext* opCtx, const std::string& path, std::vector& dbList, std::vector& filesList) { From bec98c36d509c10e6c557a592724f62a3d90b0fb Mon Sep 17 00:00:00 2001 From: Igor Solodovnikov Date: Fri, 12 Feb 2021 19:19:43 +0200 Subject: [PATCH 2/3] PSMDB-810 output more information in case of exception while copying --- .../wiredtiger/wiredtiger_kv_engine.cpp | 21 ++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/src/mongo/db/storage/wiredtiger/wiredtiger_kv_engine.cpp b/src/mongo/db/storage/wiredtiger/wiredtiger_kv_engine.cpp index 3300acf71b702..6ca20801c13c5 100644 --- a/src/mongo/db/storage/wiredtiger/wiredtiger_kv_engine.cpp +++ b/src/mongo/db/storage/wiredtiger/wiredtiger_kv_engine.cpp @@ -2081,11 +2081,26 @@ Status WiredTigerKVEngine::hotBackup(OperationContext* opCtx, const std::string& // more fine-grained copy copy_file_size(srcFile, destFile, fsize); } catch (const fs::filesystem_error& ex) { - return Status(ErrorCodes::InvalidPath, ex.what()); + return Status(ErrorCodes::InvalidPath, + "filesystem_error while copying '{}' to '{}': ({}/{}): {}"_format( + srcFile.string(), + destFile.string(), + ex.code().value(), + ex.code().message(), + ex.what())); + } catch (const std::system_error& ex) { + return Status( + ErrorCodes::InternalError, + "system_error while copying '{}' to '{}': ({}/{}): {}"_format(srcFile.string(), + destFile.string(), + ex.code().value(), + ex.code().message(), + ex.what())); } catch (const std::exception& ex) { - return Status(ErrorCodes::InternalError, ex.what()); + return Status(ErrorCodes::InternalError, + "exception while copying '{}' to '{}': {}"_format( + srcFile.string(), destFile.string(), ex.what())); } - } return Status::OK(); From 3dd2a6ef2e13f4e21b96b6cf5dc83b3afc1fe604 Mon Sep 17 00:00:00 2001 From: Igor Solodovnikov Date: Sun, 14 Feb 2021 21:13:10 +0200 Subject: [PATCH 3/3] PSMDB-810 log more info during hot backup --- src/mongo/db/storage/wiredtiger/wiredtiger_kv_engine.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/mongo/db/storage/wiredtiger/wiredtiger_kv_engine.cpp b/src/mongo/db/storage/wiredtiger/wiredtiger_kv_engine.cpp index 6ca20801c13c5..e502019a5f720 100644 --- a/src/mongo/db/storage/wiredtiger/wiredtiger_kv_engine.cpp +++ b/src/mongo/db/storage/wiredtiger/wiredtiger_kv_engine.cpp @@ -2064,11 +2064,20 @@ Status WiredTigerKVEngine::hotBackup(OperationContext* opCtx, const std::string& std::set existDirs{destPath}; // Do copy files + int fcCtr = 0; for (auto&& file : filesList) { fs::path srcFile{std::get<0>(file)}; fs::path destFile{std::get<1>(file)}; auto fsize{std::get<2>(file)}; + log() << "Beginning copy of {}/{} files in backup snapshot: {}, {} bytes"_format( + ++fcCtr, filesList.size(), srcFile.string(), fsize); + if (!fs::exists(srcFile)) { + log() << "Source file does not exist: {}"_format(srcFile.string()); + } else { + log() << "Source file size is: {} bytes"_format(fs::file_size(srcFile)); + } + try { // Try creating destination directories if needed. const fs::path destDir(destFile.parent_path());