Skip to content

Commit

Permalink
relax L0 seqno invariant for ingested files
Browse files Browse the repository at this point in the history
This is necessary to revert
cockroachdb/cockroach#39562 to support RocksDB
built without `-DNDEBUG`. Consecutive files ingested to L0 may be
assigned the same seqnum, and this PR updates the LSM validation to
allow that.

There is a longer-term fix in
facebook#5539. We should take that
later, maybe after the 19.2 release.

Test Plan: ran some tests that previously failed with corruption error
like `ENABLE_ROCKSDB_ASSERTIONS=1 make
PKG=github.com/cockroachdb/cockroach/pkg/ccl/backupccl testrace`;
verified they succeed now.
  • Loading branch information
ajkr committed Sep 26, 2019
1 parent 217d7a1 commit 25342b1
Showing 1 changed file with 23 additions and 15 deletions.
38 changes: 23 additions & 15 deletions db/version_builder.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit 25342b1

Please sign in to comment.