Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

relax L0 seqno invariant for ingested files #59

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 23 additions & 16 deletions db/version_builder.cc
Original file line number Diff line number Diff line change
Expand Up @@ -169,22 +169,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()));
SequenceNumber f2_external_file_seqno = f2->fd.smallest_seqno;
bool is_f1_ingested = f1->fd.smallest_seqno == f1->fd.largest_seqno;
if (f2_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 > f2_external_file_seqno ||
(is_f1_ingested && f1->fd.largest_seqno == f2_external_file_seqno))) {
// f1 should be newer than f2. Equal seqnos are only 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,
f2_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(f2_external_file_seqno) +
" with fileNumber " +
NumberToString(f1->fd.GetNumber()));
}
}
} else if (f1->fd.smallest_seqno <= f2->fd.smallest_seqno) {
fprintf(stderr,
Expand Down