Skip to content

Commit 21441fa

Browse files
committed
manifest: don't crosscheck AddL0Files result every time
In invariants.Enabled, we rebuild the L0 sublevels from scratch to cross-check the result of the incremental updating. However, this rebuilding reinitializes the fields inside TableMetadata (like L0Index), correcting any mistake made by `AddL0Files` (but only in invariant builds..) This change adds an `invariant.Sometimes(10)` to only do this sometimes. In the future, we will want to move out the TableMetadata fields we're modifying and cross-check those values too.
1 parent 27dd231 commit 21441fa

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

internal/manifest/version_edit.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1280,7 +1280,10 @@ func (b *BulkVersionEdit) Apply(
12801280
v.L0Sublevels, err = curr.L0Sublevels.AddL0Files(addedTables, flushSplitBytes, &v.Levels[0])
12811281
if errors.Is(err, errInvalidL0SublevelsOpt) {
12821282
err = v.InitL0Sublevels(flushSplitBytes)
1283-
} else if invariants.Enabled && err == nil {
1283+
} else if invariants.Enabled && err == nil && invariants.Sometimes(10) {
1284+
// Rebuild from scratch to verify that AddL0Files did the right thing.
1285+
// Note that NewL0Sublevels updates fields in TableMetadata like
1286+
// L0Index, so we don't want to do this every time.
12841287
copyOfSublevels, err := NewL0Sublevels(&v.Levels[0], comparer.Compare, comparer.FormatKey, flushSplitBytes)
12851288
if err != nil {
12861289
panic(fmt.Sprintf("error when regenerating sublevels: %s", err))

0 commit comments

Comments
 (0)