diff --git a/db/version_util.cc b/db/version_util.cc index 2772e3a6c38f..ec4176083fc8 100644 --- a/db/version_util.cc +++ b/db/version_util.cc @@ -7,13 +7,13 @@ #include #include +#include #include #include #include #include "db/internal_stats.h" #include "db/table_cache.h" -#include "port/port.h" #include "test_util/sync_point.h" namespace ROCKSDB_NAMESPACE { @@ -29,6 +29,10 @@ Status LoadTableHandlersHelper( std::atomic* stop) { assert(table_cache != nullptr); + if (files_meta.empty()) { + return Status::OK(); + } + std::atomic next_file_meta_idx(0); std::atomic has_error(false); Status ret; @@ -82,14 +86,15 @@ Status LoadTableHandlersHelper( } }); - std::vector threads; + std::vector threads; for (int i = 1; i < max_threads; i++) { - threads.emplace_back(load_handlers_func); + try { + threads.emplace_back(load_handlers_func); + } catch (const std::system_error&) { + break; + } } load_handlers_func(); - for (auto& t : threads) { - t.join(); - } return ret; }