From 4c35637018f3ed65ad1b2fc25852e47414e18f43 Mon Sep 17 00:00:00 2001 From: Erik Grinaker Date: Mon, 23 May 2022 15:21:48 +0000 Subject: [PATCH] storage: respect new Pebble iterator visibility Pebble recently tightened its iterator semantics such that it has a static view of the underlying reader as of the time of its creation. Previously, a batch iterator could see batch writes that occurred after the iterator was created. This patch prepares CRDB for this change. Release note: None --- pkg/storage/mvcc_test.go | 67 ---------------------------------------- 1 file changed, 67 deletions(-) diff --git a/pkg/storage/mvcc_test.go b/pkg/storage/mvcc_test.go index 8598b3c9c656..5090d8c912f1 100644 --- a/pkg/storage/mvcc_test.go +++ b/pkg/storage/mvcc_test.go @@ -951,73 +951,6 @@ func TestMVCCInvalidateIterator(t *testing.T) { } } -func TestMVCCPutAfterBatchIterCreate(t *testing.T) { - defer leaktest.AfterTest(t)() - defer log.Scope(t).Close(t) - - for _, engineImpl := range mvccEngineImpls { - t.Run(engineImpl.name, func(t *testing.T) { - engine := engineImpl.create() - defer engine.Close() - - value := MVCCValue{Value: roachpb.MakeValueFromString("foobar")} - err := engine.PutMVCC(MVCCKey{Key: testKey1, Timestamp: hlc.Timestamp{WallTime: 5}}, value) - if err != nil { - t.Fatal(err) - } - err = engine.PutMVCC(MVCCKey{Key: testKey2, Timestamp: hlc.Timestamp{WallTime: 5}}, value) - if err != nil { - t.Fatal(err) - } - err = engine.PutMVCC(MVCCKey{Key: testKey2, Timestamp: hlc.Timestamp{WallTime: 3}}, value) - if err != nil { - t.Fatal(err) - } - err = engine.PutMVCC(MVCCKey{Key: testKey3, Timestamp: hlc.Timestamp{WallTime: 5}}, value) - if err != nil { - t.Fatal(err) - } - err = engine.PutMVCC(MVCCKey{Key: testKey4, Timestamp: hlc.Timestamp{WallTime: 5}}, value) - if err != nil { - t.Fatal(err) - } - - batch := engine.NewBatch() - defer batch.Close() - txn := &roachpb.Transaction{ - TxnMeta: enginepb.TxnMeta{ - WriteTimestamp: hlc.Timestamp{WallTime: 10}, - }, - Name: "test", - Status: roachpb.PENDING, - ReadTimestamp: hlc.Timestamp{WallTime: 10}, - GlobalUncertaintyLimit: hlc.Timestamp{WallTime: 10}, - } - iter := batch.NewMVCCIterator(MVCCKeyAndIntentsIterKind, IterOptions{ - LowerBound: testKey1, - UpperBound: testKey5, - }) - defer iter.Close() - iter.SeekGE(MVCCKey{Key: testKey1, Timestamp: hlc.Timestamp{WallTime: 5}}) - iter.Next() // key2/5 - - // Lay down an intent on key3, which will go at key3/0 and sort before key3/5. - err = MVCCDelete(context.Background(), batch, nil, testKey3, txn.WriteTimestamp, hlc.ClockTimestamp{}, txn) - if err != nil { - t.Fatal(err) - } - iter.SeekGE(MVCCKey{Key: testKey3}) - if ok, err := iter.Valid(); !ok || err != nil { - t.Fatalf("expected valid iter: ok %t, err %s", ok, err.Error()) - } - // Should see the intent. - if iter.UnsafeKey().IsValue() { - t.Fatalf("expected iterator to land on an intent, got a value: %v", iter.UnsafeKey()) - } - }) - } -} - func mvccScanTest(ctx context.Context, t *testing.T, engine Engine) { if err := MVCCPut(ctx, engine, nil, testKey1, hlc.Timestamp{WallTime: 1}, hlc.ClockTimestamp{}, value1, nil); err != nil { t.Fatal(err)