Skip to content

Commit

Permalink
Merge #81662 #81702
Browse files Browse the repository at this point in the history
81662: storage: respect new Pebble iterator visibility r=jbowens a=erikgrinaker

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.

Touches cockroachdb/pebble#1640.

Release note: None

81702: roachtest: update rust-postgres blocklist r=e-mbrown a=RichardJCai

Release note: None

Fixes #81633

Co-authored-by: Erik Grinaker <[email protected]>
Co-authored-by: richardjcai <[email protected]>
  • Loading branch information
3 people committed May 24, 2022
3 parents 9a7dedb + 804d06c + df545f5 commit 7b094aa
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 77 deletions.
9 changes: 5 additions & 4 deletions pkg/cmd/roachtest/tests/rust_postgres.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,10 +108,11 @@ func registerRustPostgres(r registry.Registry) {

t.Status("building rust postgres (without test)")

blocklistName, expectedFailures, ignorelistName, ignorelist := rustPostgresBlocklists.getLists(version)
if expectedFailures == nil {
t.Fatalf("No rust-postgres blocklist defined for cockroach version %s", version)
}
blocklistName := "rustPostgresBlockList"
ignorelistName := "rustPostgresIgnoreList"
expectedFailures := rustPostgresBlocklist
ignorelist := rustPostgresIgnoreList

status := fmt.Sprintf("running cockroach version %s, using blocklist %s", version, blocklistName)
if ignorelist != nil {
status = fmt.Sprintf(
Expand Down
8 changes: 2 additions & 6 deletions pkg/cmd/roachtest/tests/rust_postgres_blocklist.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,9 @@

package tests

var rustPostgresBlocklists = blocklistsForVersion{
{"v22.1", "rustPostgresBlocklist22_1", rustPostgresBlocklist22_1, "rustPostgresIgnoreList22_1", rustPostgresIgnoreList22_1},
}

var rustPostgresBlocklist22_1 = blocklist{}
var rustPostgresBlocklist = blocklist{}

var rustPostgresIgnoreList22_1 = blocklist{
var rustPostgresIgnoreList = blocklist{
"binary_copy.read_basic": "unknown",
"binary_copy.read_big_rows": "unknown",
"binary_copy.read_many_rows": "unknown",
Expand Down
67 changes: 0 additions & 67 deletions pkg/storage/mvcc_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 7b094aa

Please sign in to comment.