From bd9f1d2d0ff7ea7beb289cb1ca230f1593ceedae Mon Sep 17 00:00:00 2001 From: Yanqin Jin Date: Fri, 24 May 2019 18:35:11 -0700 Subject: [PATCH] Fix RocksDB auto-recovery from SpaceLimit err (#5334) Summary: If RocksDB is configured with a positive max_allowed_space (via sst file manager), then the sst file manager should use this value instead of total free disk space to determine whether to clear the background error of space limit reached. In DBSSTTest.DBWithMaxSpaceAllowed, we configure a low space limit that is very likely lower than the free disk space of the test machine. Therefore, once the test db encounters a Status::SpaceLimit, error handler will call into sst file manager to start error recovery which may clear the bg error since disk free space is larger than reserved_disk_buffer_. Pull Request resolved: https://github.com/facebook/rocksdb/pull/5334 Differential Revision: D15501622 Pulled By: riversand963 fbshipit-source-id: 58035efc450b062d6b28c78c322005ec3705fb47 --- util/sst_file_manager_impl.cc | 3 +++ 1 file changed, 3 insertions(+) diff --git a/util/sst_file_manager_impl.cc b/util/sst_file_manager_impl.cc index 6a770b106..047b0c093 100644 --- a/util/sst_file_manager_impl.cc +++ b/util/sst_file_manager_impl.cc @@ -266,6 +266,9 @@ void SstFileManagerImpl::ClearError() { uint64_t free_space; Status s = env_->GetFreeSpace(path_, &free_space); + free_space = max_allowed_space_ > 0 + ? std::min(max_allowed_space_, free_space) + : free_space; if (s.ok()) { // In case of multi-DB instances, some of them may have experienced a // soft error and some a hard error. In the SstFileManagerImpl, a hard