diff --git a/db/compaction_job.cc b/db/compaction_job.cc index 8604f21f9..4e3a5ecbb 100644 --- a/db/compaction_job.cc +++ b/db/compaction_job.cc @@ -853,9 +853,6 @@ void CompactionJob::ProcessKeyValueCompaction(SubcompactionState* sub_compact) { } } - Status input_status = input->status(); - c_iter->Next(); - // Close output file if it is big enough // TODO(aekmekji): determine if file should be closed earlier than this // during subcompactions (i.e. if output size, estimated by input size, is @@ -864,6 +861,9 @@ void CompactionJob::ProcessKeyValueCompaction(SubcompactionState* sub_compact) { if (sub_compact->compaction->output_level() != 0 && sub_compact->current_output_file_size >= sub_compact->compaction->max_output_file_size()) { + Status input_status = input->status(); + c_iter->Next(); + const Slice* next_key = nullptr; if (c_iter->Valid()) { next_key = &c_iter->key(); @@ -879,6 +879,8 @@ void CompactionJob::ProcessKeyValueCompaction(SubcompactionState* sub_compact) { // files. sub_compact->compression_dict = std::move(compression_dict); } + } else { + c_iter->Next(); } }