From a9117a3490e8e051c64f709bde3285b010c6f1c9 Mon Sep 17 00:00:00 2001 From: "yite.gu" Date: Sun, 3 Jul 2022 23:16:09 -0700 Subject: [PATCH] BackupEngine: we can return immediately if GetFileSize failed (#10176) Summary: In some case, GetFileSize would be failure in copy_file_cb. If failure, we can return immediately, the subsequent code is meaningless, and add a log info let user know that problem happen here. Singed-off-by: Yite Gu Pull Request resolved: https://github.com/facebook/rocksdb/pull/10176 Reviewed By: cbi42 Differential Revision: D37510888 Pulled By: ajkr fbshipit-source-id: 044ad8c45852fd19b8cd564b11f65d40c39e296f --- utilities/backup/backup_engine.cc | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/utilities/backup/backup_engine.cc b/utilities/backup/backup_engine.cc index 37a8cfff6..f6f795993 100644 --- a/utilities/backup/backup_engine.cc +++ b/utilities/backup/backup_engine.cc @@ -1453,6 +1453,11 @@ IOStatus BackupEngineImpl::CreateNewBackupWithMetadata( if (type == kTableFile || type == kBlobFile) { io_st = db_fs_->GetFileSize(src_dirname + "/" + fname, io_options_, &size_bytes, nullptr); + if (!io_st.ok()) { + Log(options_.info_log, "GetFileSize is failed: %s", + io_st.ToString().c_str()); + return io_st; + } } EnvOptions src_env_options; switch (type) { @@ -1479,18 +1484,16 @@ IOStatus BackupEngineImpl::CreateNewBackupWithMetadata( src_env_options = src_raw_env_options; break; } - if (io_st.ok()) { - io_st = AddBackupFileWorkItem( - live_dst_paths, backup_items_to_finish, new_backup_id, - options_.share_table_files && - (type == kTableFile || type == kBlobFile), - src_dirname, fname, src_env_options, rate_limiter, type, - size_bytes, db_options.statistics.get(), size_limit_bytes, - options_.share_files_with_checksum && - (type == kTableFile || type == kBlobFile), - options.progress_callback, "" /* contents */, - checksum_func_name, checksum_val, src_temperature); - } + io_st = AddBackupFileWorkItem( + live_dst_paths, backup_items_to_finish, new_backup_id, + options_.share_table_files && + (type == kTableFile || type == kBlobFile), + src_dirname, fname, src_env_options, rate_limiter, type, + size_bytes, db_options.statistics.get(), size_limit_bytes, + options_.share_files_with_checksum && + (type == kTableFile || type == kBlobFile), + options.progress_callback, "" /* contents */, checksum_func_name, + checksum_val, src_temperature); return io_st; } /* copy_file_cb */, [&](const std::string& fname, const std::string& contents,