From 113796c49318eb230fc5451fb106be5f0733cbec Mon Sep 17 00:00:00 2001 From: Igor Canadi Date: Tue, 11 Nov 2014 06:58:47 -0800 Subject: [PATCH] Fix NewFileNumber() Summary: I mistakenly changed the behavior to ++next_file_number_ instead of next_file_number_++, as it should have been: https://github.com/facebook/rocksdb/blob/344edbb044ff5c08a43e4a6e9344c5c861552c0e/db/version_set.h#L539 Test Plan: none. not sure if this would break anything. It's just different behavior, so I'd rather not risk Reviewers: ljin, rven, yhchiang, sdong Reviewed By: sdong Subscribers: dhruba, leveldb Differential Revision: https://reviews.facebook.net/D28557 --- db/db_impl.cc | 2 -- db/version_set.h | 11 +---------- include/rocksdb/options.h | 11 ++++------- 3 files changed, 5 insertions(+), 19 deletions(-) diff --git a/db/db_impl.cc b/db/db_impl.cc index 893dfdee7..ee0f954fd 100644 --- a/db/db_impl.cc +++ b/db/db_impl.cc @@ -3003,8 +3003,6 @@ Status DBImpl::SetNewMemtableAndNewLogFile(ColumnFamilyData* cfd, if (!s.ok()) { // how do we fail if we're not creating new log? assert(creating_new_log); - // Avoid chewing through file number space in a tight loop. - versions_->ReuseLogFileNumber(new_log_number); assert(!new_mem); assert(!new_log); return s; diff --git a/db/version_set.h b/db/version_set.h index 0be8c4e1b..3c4eff353 100644 --- a/db/version_set.h +++ b/db/version_set.h @@ -535,16 +535,7 @@ class VersionSet { uint64_t current_next_file_number() const { return next_file_number_.load(); } // Allocate and return a new file number - uint64_t NewFileNumber() { return next_file_number_.fetch_add(1) + 1; } - - // Arrange to reuse "file_number" unless a newer file number has - // already been allocated. - // REQUIRES: "file_number" was returned by a call to NewFileNumber(). - void ReuseLogFileNumber(uint64_t file_number) { - auto expected = file_number + 1; - std::atomic_compare_exchange_strong(&next_file_number_, &expected, - file_number); - } + uint64_t NewFileNumber() { return next_file_number_.fetch_add(1); } // Return the last sequence number. uint64_t LastSequence() const { diff --git a/include/rocksdb/options.h b/include/rocksdb/options.h index 1656c5c41..e22ee03eb 100644 --- a/include/rocksdb/options.h +++ b/include/rocksdb/options.h @@ -625,14 +625,11 @@ struct DBOptions { // Default: false bool error_if_exists; - // If true, the implementation will do aggressive checking of the - // data it is processing and will stop early if it detects any - // errors. This may have unforeseen ramifications: for example, a - // corruption of one DB entry may cause a large number of entries to - // become unreadable or for the entire DB to become unopenable. - // If any of the writes to the database fails (Put, Delete, Merge, Write), - // the database will switch to read-only mode and fail all other + // If true, RocksDB will aggressively check consistency of the data. + // Also, if any of the writes to the database fails (Put, Delete, Merge, + // Write), the database will switch to read-only mode and fail all other // Write operations. + // In most cases you want this to be set to true. // Default: true bool paranoid_checks;