diff --git a/src/mongo/db/storage/wiredtiger/wiredtiger_kv_engine.cpp b/src/mongo/db/storage/wiredtiger/wiredtiger_kv_engine.cpp index 30f6c2fe450e7..e502019a5f720 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) { @@ -2062,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()); @@ -2079,11 +2090,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();