diff --git a/db/column_family_test.cc b/db/column_family_test.cc index 416cada256..41990b15ae 100644 --- a/db/column_family_test.cc +++ b/db/column_family_test.cc @@ -546,8 +546,9 @@ class ColumnFamilyTest INSTANTIATE_TEST_CASE_P(FormatDef, ColumnFamilyTest, testing::Values(test::kDefaultFormatVersion)); -INSTANTIATE_TEST_CASE_P(FormatLatest, ColumnFamilyTest, - testing::Values(kLatestBbtFormatVersion)); +INSTANTIATE_TEST_CASE_P( + FormatLatest, ColumnFamilyTest, + testing::Values(BlockBasedTableOptions::kLatestSupportedFormatVersion)); TEST_P(ColumnFamilyTest, DontReuseColumnFamilyID) { for (int iter = 0; iter < 3; ++iter) { @@ -737,8 +738,11 @@ INSTANTIATE_TEST_CASE_P( std::make_tuple(test::kDefaultFormatVersion, false))); INSTANTIATE_TEST_CASE_P( FormatLatest, FlushEmptyCFTestWithParam, - testing::Values(std::make_tuple(kLatestBbtFormatVersion, true), - std::make_tuple(kLatestBbtFormatVersion, false))); + testing::Values( + std::make_tuple(BlockBasedTableOptions::kLatestSupportedFormatVersion, + true), + std::make_tuple(BlockBasedTableOptions::kLatestSupportedFormatVersion, + false))); TEST_P(ColumnFamilyTest, AddDrop) { Open(); @@ -4170,7 +4174,9 @@ TEST(ColumnFamilyTest, ValidateMemtableKVChecksumOption) { // the behavior of manual flush is that it skips retaining UDTs. class ColumnFamilyRetainUDTTest : public ColumnFamilyTestBase { public: - ColumnFamilyRetainUDTTest() : ColumnFamilyTestBase(kLatestBbtFormatVersion) {} + ColumnFamilyRetainUDTTest() + : ColumnFamilyTestBase( + BlockBasedTableOptions::kLatestSupportedFormatVersion) {} void SetUp() override { db_options_.allow_concurrent_memtable_write = false; diff --git a/db/comparator_db_test.cc b/db/comparator_db_test.cc index fdd042fcd7..f9f30da000 100644 --- a/db/comparator_db_test.cc +++ b/db/comparator_db_test.cc @@ -315,8 +315,9 @@ class ComparatorDBTest INSTANTIATE_TEST_CASE_P(FormatDef, ComparatorDBTest, testing::Values(test::kDefaultFormatVersion)); -INSTANTIATE_TEST_CASE_P(FormatLatest, ComparatorDBTest, - testing::Values(kLatestBbtFormatVersion)); +INSTANTIATE_TEST_CASE_P( + FormatLatest, ComparatorDBTest, + testing::Values(BlockBasedTableOptions::kLatestSupportedFormatVersion)); TEST_P(ComparatorDBTest, Bytewise) { for (int rand_seed = 301; rand_seed < 306; rand_seed++) { diff --git a/db/db_bloom_filter_test.cc b/db/db_bloom_filter_test.cc index 789411e621..3d52a87371 100644 --- a/db/db_bloom_filter_test.cc +++ b/db/db_bloom_filter_test.cc @@ -917,14 +917,15 @@ INSTANTIATE_TEST_CASE_P( ::testing::Values( std::make_tuple(kAutoBloom, FilterPartitioning::kCoupledPartitionedFilter, - kLatestBbtFormatVersion), + BlockBasedTableOptions::kLatestSupportedFormatVersion), std::make_tuple(kAutoBloom, FilterPartitioning::kDecoupledPartitionedFilter, - kLatestBbtFormatVersion), + BlockBasedTableOptions::kLatestSupportedFormatVersion), std::make_tuple(kAutoBloom, FilterPartitioning::kUnpartitionedFilter, - kLatestBbtFormatVersion), - std::make_tuple(kAutoRibbon, FilterPartitioning::kUnpartitionedFilter, - kLatestBbtFormatVersion))); + BlockBasedTableOptions::kLatestSupportedFormatVersion), + std::make_tuple( + kAutoRibbon, FilterPartitioning::kUnpartitionedFilter, + BlockBasedTableOptions::kLatestSupportedFormatVersion))); #endif // !defined(ROCKSDB_VALGRIND_RUN) || defined(ROCKSDB_FULL_VALGRIND_RUN) TEST_F(DBBloomFilterTest, BloomFilterRate) { diff --git a/db/db_test_util.cc b/db/db_test_util.cc index 149a3ca0da..db2847b3dc 100644 --- a/db/db_test_util.cc +++ b/db/db_test_util.cc @@ -535,7 +535,8 @@ Options DBTestBase::GetOptions( } case kBlockBasedTableWithLatestFormat: { // In case different from default - table_options.format_version = kLatestBbtFormatVersion; + table_options.format_version = + BlockBasedTableOptions::kLatestSupportedFormatVersion; break; } case kOptimizeFiltersForHits: { diff --git a/include/rocksdb/table.h b/include/rocksdb/table.h index 3a71002c01..21297a01db 100644 --- a/include/rocksdb/table.h +++ b/include/rocksdb/table.h @@ -766,6 +766,11 @@ struct BlockBasedTableOptions { // who might only upgrade a few times per year. uint32_t format_version = 7; + // Latest format_version supported by this version of RocksDB for both + // reading and writing SST files. Setting format_version higher than this is + // rejected as InvalidArgument (e.g. by DB::Open() or SetOptions()). + static constexpr uint32_t kLatestSupportedFormatVersion = 8; + // When true, data blocks store keys and values separately. Keys are stored // at the beginning of the block, followed by values at the end. This can // improve read performance at a cost of a varint per restart interval (~1 bit diff --git a/table/block_based/partitioned_filter_block_test.cc b/table/block_based/partitioned_filter_block_test.cc index d63e9614d0..2a5664fd33 100644 --- a/table/block_based/partitioned_filter_block_test.cc +++ b/table/block_based/partitioned_filter_block_test.cc @@ -405,7 +405,8 @@ INSTANTIATE_TEST_CASE_P( FormatVersions, PartitionedFilterBlockTest, testing::Combine( testing::ValuesIn(std::set{ - 2, 3, 4, 5, test::kDefaultFormatVersion, kLatestBbtFormatVersion}), + 2, 3, 4, 5, test::kDefaultFormatVersion, + BlockBasedTableOptions::kLatestSupportedFormatVersion}), testing::ValuesIn(test::GetUDTTestModes()), testing::Bool())); TEST_P(PartitionedFilterBlockTest, EmptyBuilder) { diff --git a/table/format.h b/table/format.h index 1894ad11c5..b7c6cfca04 100644 --- a/table/format.h +++ b/table/format.h @@ -180,13 +180,6 @@ inline uint32_t ChecksumModifierForContext(uint32_t base_context_checksum, return modifier & all_or_nothing; } -// Latest format_version supported for both reading and writing new SST files in -// block-based format. Newer "draft" format_versions that are still in -// development are not published: they are exercised only in tests, gated behind -// the TEST-only TEST_AllowUnsupportedFormatVersion() hook, and are neither -// readable nor writable in production until finalized by bumping this constant. -constexpr uint32_t kLatestBbtFormatVersion = 8; - // Sentinel for "no format_version known yet," e.g. a Footer that has not been // populated by DecodeFrom. Deliberately larger than any real version so that // accidentally treating it as one is caught by the FormatVersionUses* @@ -213,7 +206,7 @@ static_assert(kMinSupportedBbtFormatVersionForWrite >= inline bool IsSupportedFormatVersionForRead(uint64_t magic, uint32_t version) { if (magic == kBlockBasedTableMagicNumber) { return version >= kMinSupportedBbtFormatVersionForRead && - version <= kLatestBbtFormatVersion; + version <= BlockBasedTableOptions::kLatestSupportedFormatVersion; } else if (magic == kPlainTableMagicNumber) { return version == 0; } else if (magic == kCuckooTableMagicNumber) { @@ -226,7 +219,7 @@ inline bool IsSupportedFormatVersionForRead(uint64_t magic, uint32_t version) { inline bool IsSupportedFormatVersionForWrite(uint64_t magic, uint32_t version) { if (magic == kBlockBasedTableMagicNumber) { return version >= kMinSupportedBbtFormatVersionForWrite && - version <= kLatestBbtFormatVersion; + version <= BlockBasedTableOptions::kLatestSupportedFormatVersion; } else if (magic == kPlainTableMagicNumber) { return version == 0; } else if (magic == kCuckooTableMagicNumber) { diff --git a/table/table_test.cc b/table/table_test.cc index fc36dc356f..b886a5d742 100644 --- a/table/table_test.cc +++ b/table/table_test.cc @@ -763,8 +763,9 @@ static std::vector GenerateArgList() { for (auto num_threads : compression_parallel_threads) { // format_version = 7 changes some compression handling; 8 adds the // index value-delta escape and the common-key-prefix feature. - for (uint32_t fv : {kMinSupportedBbtFormatVersionForRead, 7U, - kLatestBbtFormatVersion}) { + for (uint32_t fv : + {kMinSupportedBbtFormatVersionForRead, 7U, + BlockBasedTableOptions::kLatestSupportedFormatVersion}) { TestArgs one_arg; one_arg.type = test_type; one_arg.reverse_compare = reverse_compare; @@ -5868,12 +5869,13 @@ TEST(TableTest, UnsupportedFormatVersionConfigTest) { ASSERT_OK(s) << "format_version=" << fv << ": " << s.ToString(); } - // Test that format_version > kLatestBbtFormatVersion is rejected by + // Test that format_version > kLatestSupportedFormatVersion is rejected by // ValidateOptions (not sanitized, since it could be a future version that // requires newer code) { BlockBasedTableOptions table_options; - table_options.format_version = kLatestBbtFormatVersion + 1; + table_options.format_version = + BlockBasedTableOptions::kLatestSupportedFormatVersion + 1; BlockBasedTableFactory factory(table_options); ColumnFamilyOptions cf_opts; diff --git a/test_util/testutil.cc b/test_util/testutil.cc index 50339a799f..bf7c4216b5 100644 --- a/test_util/testutil.cc +++ b/test_util/testutil.cc @@ -45,7 +45,7 @@ const std::set kFooterFormatVersionsToTest{ 6U, // In case any interesting future changes kDefaultFormatVersion, - kLatestBbtFormatVersion, + BlockBasedTableOptions::kLatestSupportedFormatVersion, // Unpublished draft format_version 8 (index value-delta escape). Writing it // requires the TEST_AllowUnsupportedFormatVersion() opt-in, enabled by the // test files that instantiate parameterized suites over this set. diff --git a/tools/sst_dump_tool.cc b/tools/sst_dump_tool.cc index 1f2f3306e1..be7f25b343 100644 --- a/tools/sst_dump_tool.cc +++ b/tools/sst_dump_tool.cc @@ -603,7 +603,7 @@ int SSTDumpTool::Run(int argc, char const* const* argv, Options options) { } bbto.block_size = 16384; // A popular choice for default // Maximize compression features available - bbto.format_version = kLatestBbtFormatVersion; + bbto.format_version = BlockBasedTableOptions::kLatestSupportedFormatVersion; for (int i = 1; i < argc; i++) { if (strncmp(argv[i], "--env_uri=", 10) == 0) {