Skip to content

Commit

Permalink
storage: add TestMVCCHistories metamorphic param for TBIs
Browse files Browse the repository at this point in the history
This patch adds the metamorphic test parameter
`mvcc-histories-separate-engine-blocks`, which will configure Pebble
with very small blocks and trigger a flush after every command. This
may uncover bugs in TBI optimizations.

Release justification: non-production code changes

Release note: None
  • Loading branch information
erikgrinaker committed Aug 30, 2022
1 parent f200792 commit 2ea11a4
Showing 1 changed file with 20 additions and 1 deletion.
21 changes: 20 additions & 1 deletion pkg/storage/mvcc_history_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ var (
"engine", "readonly", "batch", "snapshot").(string)
sstIterVerify = util.ConstantWithMetamorphicTestBool("mvcc-histories-sst-iter-verify", false)
metamorphicIteratorSeed = util.ConstantWithMetamorphicTestRange("mvcc-metamorphic-iterator-seed", 0, 0, 100000) // 0 = disabled
separateEngineBlocks = util.ConstantWithMetamorphicTestBool("mvcc-histories-separate-engine-blocks", false)
)

// TestMVCCHistories verifies that sequences of MVCC reads and writes
Expand Down Expand Up @@ -156,8 +157,22 @@ func TestMVCCHistories(t *testing.T) {
const statsTS = 100e9

datadriven.Walk(t, testutils.TestDataPath(t, "mvcc_histories"), func(t *testing.T, path string) {
engineOpts := []ConfigOption{CacheSize(1 << 20 /* 1 MiB */), ForTesting}
// If enabled by metamorphic parameter, use very small blocks to provoke TBI
// optimization. We'll also flush after each command.
if separateEngineBlocks {
engineOpts = append(engineOpts, func(cfg *engineConfig) error {
cfg.Opts.DisableAutomaticCompactions = true
for i := range cfg.Opts.Levels {
cfg.Opts.Levels[i].BlockSize = 1
cfg.Opts.Levels[i].IndexBlockSize = 1
}
return nil
})
}

// We start from a clean slate in every test file.
engine, err := Open(ctx, InMemory(), CacheSize(1<<20 /* 1 MiB */), ForTesting)
engine, err := Open(ctx, InMemory(), engineOpts...)
if err != nil {
t.Fatal(err)
}
Expand Down Expand Up @@ -530,6 +545,10 @@ func TestMVCCHistories(t *testing.T) {
// Run the command.
foundErr = cmd.fn(e)

if separateEngineBlocks && dataChange {
require.NoError(t, e.engine.Flush())
}

if trace {
// If tracing is enabled, we report the intermediate results
// after each individual step in the script.
Expand Down

0 comments on commit 2ea11a4

Please sign in to comment.