From 13e6c8e97ac2d6cbdf0777b67f492fb45d2afe65 Mon Sep 17 00:00:00 2001 From: Yueh-Hsuan Chiang <yhchiang@fb.com> Date: Mon, 11 Apr 2016 20:15:52 -0700 Subject: [PATCH] Relax an assertion in Compaction::ShouldStopBefore Summary: In some case, it is possible to have two concesutive SST files might sharing same boundary keys. However, in the assertion in Compaction::ShouldStopBefore, it exclude such possibility. This patch fix this issue by relaxing the assertion to allow the equal case. Test Plan: rocksdb tests Reviewers: IslamAbdelRahman, kradhakrishnan, sdong Reviewed By: sdong Subscribers: andrewkr, dhruba, leveldb Differential Revision: https://reviews.facebook.net/D55875 --- db/compaction_job.cc | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/db/compaction_job.cc b/db/compaction_job.cc index 487490f57..527f7408d 100644 --- a/db/compaction_job.cc +++ b/db/compaction_job.cc @@ -104,13 +104,12 @@ struct CompactionJob::SubcompactionState { uint64_t num_output_records; CompactionJobStats compaction_job_stats; uint64_t approx_size; - // An index that used to speed up Compaction::ShouldStopBefore(). + // An index that used to speed up ShouldStopBefore(). size_t grandparent_index = 0; // The number of bytes overlapping between the current output and - // grandparent files used in Compaction::ShouldStopBefore(). + // grandparent files used in ShouldStopBefore(). uint64_t overlapped_bytes = 0; - // A flag determine whether the key has been seen in - // Compaction::ShouldStopBefore() + // A flag determine whether the key has been seen in ShouldStopBefore() bool seen_key = false; SubcompactionState(Compaction* c, Slice* _start, Slice* _end, @@ -174,7 +173,7 @@ struct CompactionJob::SubcompactionState { assert(grandparent_index + 1 >= grandparents.size() || icmp->Compare( grandparents[grandparent_index]->largest.Encode(), - grandparents[grandparent_index + 1]->smallest.Encode()) < 0); + grandparents[grandparent_index + 1]->smallest.Encode()) <= 0); grandparent_index++; } seen_key = true;