Skip to content

Commit e493f2f

Browse files
committed
Don't compact with zero input files
Summary: We have an issue with internal service trying to run compaction with zero input files: 2014/02/07-02:26:58.386531 7f79117ec700 Compaction start summary: Base version 1420 Base level 3, seek compaction:0, inputs:[ϛ~^Qy^?],[] 2014/02/07-02:26:58.386539 7f79117ec700 Compacted 0@3 + 0@4 files => 0 bytes There are two issues: * inputsummary is printing out junk * it's constantly retrying (since I guess madeProgress is true), so it prints out a lot of data in the LOG file (40GB in one day). I read through the Level compaction picker and added some failure condition if input[0] is empty. I think PickCompaction() should not return compaction with zero input files with this change. I'm not confident enough to add an assertion though :) Test Plan: make check Reviewers: dhruba, haobo, sdong, kailiu Reviewed By: haobo CC: leveldb Differential Revision: https://reviews.facebook.net/D16005
1 parent 1ad0c2f commit e493f2f

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

db/compaction.cc

+2-3
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,7 @@ static void FileSizeSummary(unsigned long long sz, char* output, int len) {
197197

198198
static int InputSummary(std::vector<FileMetaData*>& files, char* output,
199199
int len) {
200+
*output = '\0';
200201
int write = 0;
201202
for (unsigned int i = 0; i < files.size(); i++) {
202203
int sz = len - write;
@@ -233,9 +234,7 @@ void Compaction::Summary(char* output, int len) {
233234
return;
234235
}
235236

236-
if (inputs_[1].size()) {
237-
write += InputSummary(inputs_[1], output+write, len-write);
238-
}
237+
write += InputSummary(inputs_[1], output+write, len-write);
239238
if (write < 0 || write >= len) {
240239
return;
241240
}

db/compaction_picker.cc

+5-1
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,11 @@ bool CompactionPicker::ExpandWhileOverlapping(Compaction* c) {
178178
// If, after the expansion, there are files that are already under
179179
// compaction, then we must drop/cancel this compaction.
180180
int parent_index = -1;
181-
if (FilesInCompaction(c->inputs_[0]) ||
181+
if (c->inputs_[0].empty()) {
182+
Log(options_->info_log,
183+
"ExpandWhileOverlapping() failure because zero input files");
184+
}
185+
if (c->inputs_[0].empty() || FilesInCompaction(c->inputs_[0]) ||
182186
(c->level() != c->output_level() &&
183187
ParentRangeInCompaction(c->input_version_, &smallest, &largest, level,
184188
&parent_index))) {

0 commit comments

Comments
 (0)