Skip to content

Commit 62b8a7f

Browse files
craig[bot]jbowens
andcommitted
Merge #148524
148524: storage/metamorphic: run scans on batches as well r=RaduBerinde a=jbowens The metamorphic test did not previously run scan operations against readers other than the Engine due to a limitation of RocksDB. This commit addresses the comment, performing scans against batches and engine state alike. Epic: none Release note: none Co-authored-by: Jackson Owens <[email protected]>
2 parents 4c2edf3 + 97d93ef commit 62b8a7f

File tree

1 file changed

+15
-13
lines changed

1 file changed

+15
-13
lines changed

pkg/storage/metamorphic/operations.go

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -111,23 +111,25 @@ func closeItersOnBatch(m *metaTestRunner, reader readWriterID) (results []opRefe
111111
func generateMVCCScan(
112112
ctx context.Context, m *metaTestRunner, reverse bool, inconsistent bool, args []string,
113113
) *mvccScanOp {
114-
key := m.keyGenerator.parse(args[0])
115-
endKey := m.keyGenerator.parse(args[1])
114+
reader := readWriterID(args[0])
115+
key := m.keyGenerator.parse(args[1])
116+
endKey := m.keyGenerator.parse(args[2])
116117
if endKey.Less(key) {
117118
key, endKey = endKey, key
118119
}
119120
var ts hlc.Timestamp
120121
var txn txnID
121122
if inconsistent {
122-
ts = m.pastTSGenerator.parse(args[2])
123+
ts = m.pastTSGenerator.parse(args[3])
123124
} else {
124-
txn = txnID(args[2])
125+
txn = txnID(args[3])
125126
}
126-
maxKeys := int64(m.floatGenerator.parse(args[3]) * 32)
127-
targetBytes := int64(m.floatGenerator.parse(args[4]) * (1 << 20))
128-
allowEmpty := m.boolGenerator.parse(args[5])
127+
maxKeys := int64(m.floatGenerator.parse(args[4]) * 32)
128+
targetBytes := int64(m.floatGenerator.parse(args[5]) * (1 << 20))
129+
allowEmpty := m.boolGenerator.parse(args[6])
129130
return &mvccScanOp{
130131
m: m,
132+
reader: reader,
131133
key: key.Key,
132134
endKey: endKey.Key,
133135
ts: ts,
@@ -427,6 +429,7 @@ func (m mvccFindSplitKeyOp) run(ctx context.Context) string {
427429

428430
type mvccScanOp struct {
429431
m *metaTestRunner
432+
reader readWriterID
430433
key roachpb.Key
431434
endKey roachpb.Key
432435
ts hlc.Timestamp
@@ -439,17 +442,13 @@ type mvccScanOp struct {
439442
}
440443

441444
func (m mvccScanOp) run(ctx context.Context) string {
445+
reader := m.m.getReadWriter(m.reader)
442446
var txn *roachpb.Transaction
443447
if !m.inconsistent {
444448
txn = m.m.getTxn(m.txn)
445449
m.ts = txn.ReadTimestamp
446450
}
447-
// While MVCCScanning on a batch works in Pebble, it does not in rocksdb.
448-
// This is due to batch iterators not supporting SeekForPrev. For now, use
449-
// m.engine instead of a readWriterGenerator-generated engine.Reader, otherwise
450-
// we will try MVCCScanning on batches and produce diffs between runs on
451-
// different engines that don't point to an actual issue.
452-
result, err := storage.MVCCScan(ctx, m.m.engine, m.key, m.endKey, m.ts, storage.MVCCScanOptions{
451+
result, err := storage.MVCCScan(ctx, reader, m.key, m.endKey, m.ts, storage.MVCCScanOptions{
453452
Inconsistent: m.inconsistent,
454453
Tombstones: true,
455454
Reverse: m.reverse,
@@ -1143,6 +1142,7 @@ var opGenerators = []opGenerator{
11431142
return generateMVCCScan(ctx, m, false, false, args)
11441143
},
11451144
operands: []operandType{
1145+
operandReadWriter,
11461146
operandMVCCKey,
11471147
operandMVCCKey,
11481148
operandTransaction,
@@ -1159,6 +1159,7 @@ var opGenerators = []opGenerator{
11591159
return generateMVCCScan(ctx, m, false, true, args)
11601160
},
11611161
operands: []operandType{
1162+
operandReadWriter,
11621163
operandMVCCKey,
11631164
operandMVCCKey,
11641165
operandPastTS,
@@ -1175,6 +1176,7 @@ var opGenerators = []opGenerator{
11751176
return generateMVCCScan(ctx, m, true, false, args)
11761177
},
11771178
operands: []operandType{
1179+
operandReadWriter,
11781180
operandMVCCKey,
11791181
operandMVCCKey,
11801182
operandTransaction,

0 commit comments

Comments
 (0)