diff --git a/HISTORY.md b/HISTORY.md index 316276e18..9ea62c803 100644 --- a/HISTORY.md +++ b/HISTORY.md @@ -18,6 +18,7 @@ * Fixed a memory safety bug when using a SecondaryCache with `block_cache_compressed`. `block_cache_compressed` no longer attempts to use SecondaryCache features. * Fixed a regression in scan for async_io. During seek, valid buffers were getting cleared causing a regression. * Tiered Storage: fixed excessive keys written to penultimate level in non-debug builds. +* Fixed a bug that multi-level FIFO compaction deletes one file in non-L0 even when `CompactionOptionsFIFO::max_table_files_size` is no exceeded since #10348 or 7.8.0. ### New Features * Add basic support for user-defined timestamp to Merge (#10819). diff --git a/db/compaction/compaction_picker_fifo.cc b/db/compaction/compaction_picker_fifo.cc index adf16a36d..dd6f86fa7 100644 --- a/db/compaction/compaction_picker_fifo.cc +++ b/db/compaction/compaction_picker_fifo.cc @@ -233,7 +233,8 @@ Compaction* FIFOCompactionPicker::PickSizeCompaction( break; } } - } else { + } else if (total_size > + mutable_cf_options.compaction_options_fifo.max_table_files_size) { // If the last level is non-L0, we actually don't know which file is // logically the oldest since the file creation time only represents // when this file was compacted to this level, which is independent @@ -248,15 +249,27 @@ Compaction* FIFOCompactionPicker::PickSizeCompaction( inputs[0].files.push_back(f); char tmp_fsize[16]; AppendHumanBytes(f->fd.GetFileSize(), tmp_fsize, sizeof(tmp_fsize)); - ROCKS_LOG_BUFFER(log_buffer, - "[%s] FIFO compaction: picking file %" PRIu64 - " with size %s for deletion", - cf_name.c_str(), f->fd.GetNumber(), tmp_fsize); + ROCKS_LOG_BUFFER( + log_buffer, + "[%s] FIFO compaction: picking file %" PRIu64 + " with size %s for deletion under total size %" PRIu64 + " vs max table files size %" PRIu64, + cf_name.c_str(), f->fd.GetNumber(), tmp_fsize, total_size, + mutable_cf_options.compaction_options_fifo.max_table_files_size); + if (total_size <= mutable_cf_options.compaction_options_fifo.max_table_files_size) { break; } } + } else { + ROCKS_LOG_BUFFER( + log_buffer, + "[%s] FIFO compaction: nothing to do. Total size %" PRIu64 + ", max size %" PRIu64 "\n", + cf_name.c_str(), total_size, + mutable_cf_options.compaction_options_fifo.max_table_files_size); + return nullptr; } Compaction* c = new Compaction(