From 2ea11a49c82d5f9f4fc32fc7b6eeeefd2e64d01c Mon Sep 17 00:00:00 2001 From: Erik Grinaker Date: Tue, 16 Aug 2022 19:59:01 +0000 Subject: [PATCH] storage: add `TestMVCCHistories` metamorphic param for TBIs 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 --- pkg/storage/mvcc_history_test.go | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/pkg/storage/mvcc_history_test.go b/pkg/storage/mvcc_history_test.go index d9110f58d5ed..1e0b2ccdfeba 100644 --- a/pkg/storage/mvcc_history_test.go +++ b/pkg/storage/mvcc_history_test.go @@ -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 @@ -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) } @@ -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.