diff --git a/db/db_iter.cc b/db/db_iter.cc index bfde03d17..07c8d9e0f 100644 --- a/db/db_iter.cc +++ b/db/db_iter.cc @@ -144,7 +144,7 @@ class DBIter: public Iterator { if (prop == nullptr) { return Status::InvalidArgument("prop is nullptr"); } - if (prop_name == "rocksdb.iterator.version-number") { + if (prop_name == "rocksdb.iterator.super-version-number") { // First try to pass the value returned from inner iterator. if (!iter_->GetProperty(prop_name, prop).ok()) { *prop = ToString(version_number_); diff --git a/db/db_properties_test.cc b/db/db_properties_test.cc index dbfdac970..60e04cfad 100644 --- a/db/db_properties_test.cc +++ b/db/db_properties_test.cc @@ -92,11 +92,14 @@ TEST_F(DBPropertiesTest, Empty) { TEST_F(DBPropertiesTest, CurrentVersionNumber) { uint64_t v1, v2, v3; - ASSERT_TRUE(dbfull()->GetIntProperty("rocksdb.current_version_number", &v1)); + ASSERT_TRUE( + dbfull()->GetIntProperty("rocksdb.current-super-version-number", &v1)); Put("12345678", ""); - ASSERT_TRUE(dbfull()->GetIntProperty("rocksdb.current_version_number", &v2)); + ASSERT_TRUE( + dbfull()->GetIntProperty("rocksdb.current-super-version-number", &v2)); Flush(); - ASSERT_TRUE(dbfull()->GetIntProperty("rocksdb.current_version_number", &v3)); + ASSERT_TRUE( + dbfull()->GetIntProperty("rocksdb.current-super-version-number", &v3)); ASSERT_EQ(v1, v2); ASSERT_GT(v3, v2); diff --git a/db/db_tailing_iter_test.cc b/db/db_tailing_iter_test.cc index 16edb64aa..bfb62926e 100644 --- a/db/db_tailing_iter_test.cc +++ b/db/db_tailing_iter_test.cc @@ -668,21 +668,21 @@ TEST_F(DBTestTailingIterator, ForwardIteratorVersionProperty) { std::unique_ptr iter(db_->NewIterator(read_options)); iter->Seek("foo"); std::string prop_value; - ASSERT_OK( - iter->GetProperty("rocksdb.iterator.version-number", &prop_value)); + ASSERT_OK(iter->GetProperty("rocksdb.iterator.super-version-number", + &prop_value)); v1 = static_cast(std::atoi(prop_value.c_str())); Put("foo1", "bar1"); Flush(); - ASSERT_OK( - iter->GetProperty("rocksdb.iterator.version-number", &prop_value)); + ASSERT_OK(iter->GetProperty("rocksdb.iterator.super-version-number", + &prop_value)); v2 = static_cast(std::atoi(prop_value.c_str())); iter->Seek("f"); - ASSERT_OK( - iter->GetProperty("rocksdb.iterator.version-number", &prop_value)); + ASSERT_OK(iter->GetProperty("rocksdb.iterator.super-version-number", + &prop_value)); v3 = static_cast(std::atoi(prop_value.c_str())); ASSERT_EQ(v1, v2); @@ -693,8 +693,8 @@ TEST_F(DBTestTailingIterator, ForwardIteratorVersionProperty) { std::unique_ptr iter(db_->NewIterator(read_options)); iter->Seek("foo"); std::string prop_value; - ASSERT_OK( - iter->GetProperty("rocksdb.iterator.version-number", &prop_value)); + ASSERT_OK(iter->GetProperty("rocksdb.iterator.super-version-number", + &prop_value)); v4 = static_cast(std::atoi(prop_value.c_str())); } ASSERT_EQ(v3, v4); diff --git a/db/db_test2.cc b/db/db_test2.cc index c2b1770c7..1764131ac 100644 --- a/db/db_test2.cc +++ b/db/db_test2.cc @@ -21,7 +21,8 @@ TEST_F(DBTest2, IteratorPropertyVersionNumber) { Put("", ""); Iterator* iter1 = db_->NewIterator(ReadOptions()); std::string prop_value; - ASSERT_OK(iter1->GetProperty("rocksdb.iterator.version-number", &prop_value)); + ASSERT_OK( + iter1->GetProperty("rocksdb.iterator.super-version-number", &prop_value)); uint64_t version_number1 = static_cast(std::atoi(prop_value.c_str())); @@ -29,7 +30,8 @@ TEST_F(DBTest2, IteratorPropertyVersionNumber) { Flush(); Iterator* iter2 = db_->NewIterator(ReadOptions()); - ASSERT_OK(iter2->GetProperty("rocksdb.iterator.version-number", &prop_value)); + ASSERT_OK( + iter2->GetProperty("rocksdb.iterator.super-version-number", &prop_value)); uint64_t version_number2 = static_cast(std::atoi(prop_value.c_str())); @@ -38,14 +40,16 @@ TEST_F(DBTest2, IteratorPropertyVersionNumber) { Put("", ""); Iterator* iter3 = db_->NewIterator(ReadOptions()); - ASSERT_OK(iter3->GetProperty("rocksdb.iterator.version-number", &prop_value)); + ASSERT_OK( + iter3->GetProperty("rocksdb.iterator.super-version-number", &prop_value)); uint64_t version_number3 = static_cast(std::atoi(prop_value.c_str())); ASSERT_EQ(version_number2, version_number3); iter1->SeekToFirst(); - ASSERT_OK(iter1->GetProperty("rocksdb.iterator.version-number", &prop_value)); + ASSERT_OK( + iter1->GetProperty("rocksdb.iterator.super-version-number", &prop_value)); uint64_t version_number1_new = static_cast(std::atoi(prop_value.c_str())); ASSERT_EQ(version_number1, version_number1_new); diff --git a/db/forward_iterator.cc b/db/forward_iterator.cc index 35439c75e..bbca88f9c 100644 --- a/db/forward_iterator.cc +++ b/db/forward_iterator.cc @@ -474,7 +474,7 @@ Status ForwardIterator::status() const { Status ForwardIterator::GetProperty(std::string prop_name, std::string* prop) { assert(prop != nullptr); - if (prop_name == "rocksdb.iterator.version-number") { + if (prop_name == "rocksdb.iterator.super-version-number") { *prop = ToString(sv_->version_number); return Status::OK(); } diff --git a/db/internal_stats.cc b/db/internal_stats.cc index 4fa38bb1f..a554f0b85 100644 --- a/db/internal_stats.cc +++ b/db/internal_stats.cc @@ -132,7 +132,8 @@ static const std::string is_file_deletions_enabled = static const std::string num_snapshots = "num-snapshots"; static const std::string oldest_snapshot_time = "oldest-snapshot-time"; static const std::string num_live_versions = "num-live-versions"; -static const std::string current_version_number = "current_version_number"; +static const std::string current_version_number = + "current-super-version-number"; static const std::string estimate_live_data_size = "estimate-live-data-size"; static const std::string base_level = "base-level"; static const std::string total_sst_files_size = "total-sst-files-size"; @@ -192,7 +193,7 @@ const std::string DB::Properties::kOldestSnapshotTime = rocksdb_prefix + oldest_snapshot_time; const std::string DB::Properties::kNumLiveVersions = rocksdb_prefix + num_live_versions; -const std::string DB::Properties::kCurrentVersionNumber = +const std::string DB::Properties::kCurrentSuperVersionNumber = rocksdb_prefix + current_version_number; const std::string DB::Properties::kEstimateLiveDataSize = rocksdb_prefix + estimate_live_data_size; @@ -257,8 +258,8 @@ const std::unordered_mapGetSuperVersionNumber(); return true; } diff --git a/db/internal_stats.h b/db/internal_stats.h index 3d5580228..03b2bd882 100644 --- a/db/internal_stats.h +++ b/db/internal_stats.h @@ -328,8 +328,8 @@ class InternalStats { bool HandleNumSnapshots(uint64_t* value, DBImpl* db, Version* version); bool HandleOldestSnapshotTime(uint64_t* value, DBImpl* db, Version* version); bool HandleNumLiveVersions(uint64_t* value, DBImpl* db, Version* version); - bool HandleCurrentVersionNumber(uint64_t* value, DBImpl* db, - Version* version); + bool HandleCurrentSuperVersionNumber(uint64_t* value, DBImpl* db, + Version* version); bool HandleIsFileDeletionsEnabled(uint64_t* value, DBImpl* db, Version* version); bool HandleBaseLevel(uint64_t* value, DBImpl* db, Version* version); diff --git a/include/rocksdb/db.h b/include/rocksdb/db.h index 9a0022dfa..d05c04ea1 100644 --- a/include/rocksdb/db.h +++ b/include/rocksdb/db.h @@ -444,8 +444,11 @@ class DB { // by iterators or unfinished compactions. static const std::string kNumLiveVersions; - // "rocksdb.current-version-number" - returns number of curent LSM version. - static const std::string kCurrentVersionNumber; + // "rocksdb.current-super-version-number" - returns number of curent LSM + // version. It is a uint64_t integer number, incremented after there is + // any change to the LSM tree. The number is not preserved after restarting + // the DB. After DB restart, it will start from 0 again. + static const std::string kCurrentSuperVersionNumber; // "rocksdb.estimate-live-data-size" - returns an estimate of the amount of // live data in bytes. @@ -507,7 +510,7 @@ class DB { // "rocksdb.num-snapshots" // "rocksdb.oldest-snapshot-time" // "rocksdb.num-live-versions" - // "rocksdb.current_version_number" + // "rocksdb.current-super-version-number" // "rocksdb.estimate-live-data-size" // "rocksdb.total-sst-files-size" // "rocksdb.base-level" diff --git a/include/rocksdb/iterator.h b/include/rocksdb/iterator.h index 7838d8912..7da37ec33 100644 --- a/include/rocksdb/iterator.h +++ b/include/rocksdb/iterator.h @@ -105,8 +105,9 @@ class Iterator : public Cleanable { // - DB tables were created with // BlockBasedTableOptions::use_delta_encoding // set to false. - // Property "rocksdb.iterator.version-number": - // Number of LSM version used by the iterator. + // Property "rocksdb.iterator.super-version-number": + // LSM version used by the iterator. The same format as DB Property + // kCurrentSuperVersionNumber. See its comment for more information. virtual Status GetProperty(std::string prop_name, std::string* prop); private: