diff --git a/db/version_builder.cc b/db/version_builder.cc index 598469a8e24..3fd4742efc1 100644 --- a/db/version_builder.cc +++ b/db/version_builder.cc @@ -170,21 +170,29 @@ class VersionBuilder::Rep { if (f2->fd.smallest_seqno == f2->fd.largest_seqno) { // This is an external file that we ingested SequenceNumber external_file_seqno = f2->fd.smallest_seqno; - if (!(external_file_seqno < f1->fd.largest_seqno || - external_file_seqno == 0)) { - fprintf(stderr, - "L0 file with seqno %" PRIu64 " %" PRIu64 - " vs. file with global_seqno %" PRIu64 "\n", - f1->fd.smallest_seqno, f1->fd.largest_seqno, - external_file_seqno); - return Status::Corruption("L0 file with seqno " + - NumberToString(f1->fd.smallest_seqno) + - " " + - NumberToString(f1->fd.largest_seqno) + - " vs. file with global_seqno" + - NumberToString(external_file_seqno) + - " with fileNumber " + - NumberToString(f1->fd.GetNumber())); + bool is_f1_ingested = f1->fd.smallest_seqno == f1->fd.largest_seqno; + if (external_file_seqno != 0) { + // This file's seqnos were not zeroed so we can use its seqnos to + // determine it is ordered properly. + if (f1->fd.largest_seqno < external_file_seqno || + (!is_f1_ingested && + f1->fd.largest_seqno == external_file_seqno)) { + // Consecutive files having equal seqnos is allowed when both + // files were ingested. + fprintf(stderr, + "L0 file with seqno %" PRIu64 " %" PRIu64 + " vs. file with global_seqno %" PRIu64 "\n", + f1->fd.smallest_seqno, f1->fd.largest_seqno, + external_file_seqno); + return Status::Corruption("L0 file with seqno " + + NumberToString(f1->fd.smallest_seqno) + + " " + + NumberToString(f1->fd.largest_seqno) + + " vs. file with global_seqno" + + NumberToString(external_file_seqno) + + " with fileNumber " + + NumberToString(f1->fd.GetNumber())); + } } } else if (f1->fd.smallest_seqno <= f2->fd.smallest_seqno) { fprintf(stderr,