use bottommost compression when base level is bottommost

Summary:
The previous compression type selection caused unexpected behavior when the base level was also the bottommost level. The following sequence of events could happen:

- full compaction generates files with `bottommost_compression` type
- now base level is bottommost level since all files are in the same level
- any compaction causes files to be rewritten `compression_per_level` type since bottommost compression didn't apply to base level

I changed the code to make bottommost compression apply to base level.
Closes https://github.com/facebook/rocksdb/pull/3141

Differential Revision: D6264614

Pulled By: ajkr

fbshipit-source-id: d7aaa8675126896684154a1f2c9034d6214fde82
main
Andrew Kryczka 7 years ago committed by Facebook Github Bot
parent 5e9e5a4702
commit 93f69cb93a
  1. 2
      db/compaction_picker.cc
  2. 2
      db/db_test2.cc
  3. 3
      include/rocksdb/options.h

@ -89,7 +89,7 @@ CompressionType GetCompressionType(const ImmutableCFOptions& ioptions,
// If bottommost_compression is set and we are compacting to the // If bottommost_compression is set and we are compacting to the
// bottommost level then we should use it. // bottommost level then we should use it.
if (ioptions.bottommost_compression != kDisableCompressionOption && if (ioptions.bottommost_compression != kDisableCompressionOption &&
level > base_level && level >= (vstorage->num_non_empty_levels() - 1)) { level >= (vstorage->num_non_empty_levels() - 1)) {
return ioptions.bottommost_compression; return ioptions.bottommost_compression;
} }
// If the user has specified a different compression level for each level, // If the user has specified a different compression level for each level,

@ -1152,7 +1152,7 @@ class CompactionCompressionListener : public EventListener {
} }
if (db_options_->bottommost_compression != kDisableCompressionOption && if (db_options_->bottommost_compression != kDisableCompressionOption &&
ci.output_level == bottommost_level && ci.output_level >= 2) { ci.output_level == bottommost_level) {
ASSERT_EQ(ci.compression, db_options_->bottommost_compression); ASSERT_EQ(ci.compression, db_options_->bottommost_compression);
} else if (db_options_->compression_per_level.size() != 0) { } else if (db_options_->compression_per_level.size() != 0) {
ASSERT_EQ(ci.compression, ASSERT_EQ(ci.compression,

@ -205,8 +205,7 @@ struct ColumnFamilyOptions : public AdvancedColumnFamilyOptions {
CompressionType compression; CompressionType compression;
// Compression algorithm that will be used for the bottommost level that // Compression algorithm that will be used for the bottommost level that
// contain files. If level-compaction is used, this option will only affect // contain files.
// levels after base level.
// //
// Default: kDisableCompressionOption (Disabled) // Default: kDisableCompressionOption (Disabled)
CompressionType bottommost_compression = kDisableCompressionOption; CompressionType bottommost_compression = kDisableCompressionOption;

Loading…
Cancel
Save