-
Notifications
You must be signed in to change notification settings - Fork 3.9k
/
Copy pathlock_table_iterator_test.go
641 lines (588 loc) · 18.9 KB
/
lock_table_iterator_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
// Copyright 2023 The Cockroach Authors.
//
// Use of this software is governed by the Business Source License
// included in the file licenses/BSL.txt.
//
// As of the Change Date specified in that file, in accordance with
// the Business Source License, use of this software will be governed
// by the Apache License, Version 2.0, included in the file
// licenses/APL.txt.
package storage
import (
"bytes"
"fmt"
"math/rand"
"reflect"
"strings"
"testing"
"testing/quick"
"github.com/cockroachdb/cockroach/pkg/keys"
"github.com/cockroachdb/cockroach/pkg/kv/kvserver/concurrency/lock"
"github.com/cockroachdb/cockroach/pkg/roachpb"
"github.com/cockroachdb/cockroach/pkg/storage/enginepb"
"github.com/cockroachdb/cockroach/pkg/testutils/datapathutils"
"github.com/cockroachdb/cockroach/pkg/util/leaktest"
"github.com/cockroachdb/cockroach/pkg/util/log"
"github.com/cockroachdb/cockroach/pkg/util/protoutil"
"github.com/cockroachdb/cockroach/pkg/util/randutil"
"github.com/cockroachdb/cockroach/pkg/util/uint128"
"github.com/cockroachdb/cockroach/pkg/util/uuid"
"github.com/cockroachdb/datadriven"
"github.com/cockroachdb/pebble"
"github.com/stretchr/testify/require"
)
func scanLockTableKey(t *testing.T, d *datadriven.TestData, field string) roachpb.Key {
var k string
d.ScanArgs(t, field, &k)
var rk roachpb.Key
if k == "nil" {
rk = nil
} else if strings.HasPrefix(k, "Global/") {
rk = roachpb.Key(k[7:])
} else {
rk, _ = keys.LockTableSingleKey(roachpb.Key(k), nil)
}
return rk
}
func printLockTableKey(k roachpb.Key) string {
if len(k) == 0 {
return "nil"
}
lk, err := keys.DecodeLockTableSingleKey(k)
if err != nil {
return fmt.Sprintf("Global/%s", string(k))
}
return string(lk)
}
func scanLockStrength(t *testing.T, td *datadriven.TestData, field string) lock.Strength {
var strS string
td.ScanArgs(t, field, &strS)
switch strS {
case "shared":
return lock.Shared
case "exclusive":
return lock.Exclusive
case "intent":
return lock.Intent
default:
t.Fatalf("unknown lock strength: %s", strS)
return 0
}
}
func scanTxnID(t *testing.T, td *datadriven.TestData, field string) uuid.UUID {
var txn int
td.ScanArgs(t, field, &txn)
return uuid.FromUint128(uint128.FromInts(0, uint64(txn)))
}
func checkAndOutputLockTableIterator(
iter *LockTableIterator, b *strings.Builder, valid bool, err error,
) {
state := pebble.IterExhausted
if valid {
state = pebble.IterValid
}
checkAndOutputLockTableIteratorWithState(iter, b, state, err)
}
func checkAndOutputLockTableIteratorWithState(
iter *LockTableIterator, b *strings.Builder, state pebble.IterValidityState, err error,
) {
if err != nil {
fmt.Fprintf(b, "output: err: %s\n", err)
return
}
if state != pebble.IterValid {
switch state {
case pebble.IterExhausted:
fmt.Fprintf(b, "output: . (exhausted)\n")
case pebble.IterAtLimit:
fmt.Fprintf(b, "output: . (at limit)\n")
default:
fmt.Fprintf(b, "output: err: unexpected state %d\n", state)
}
return
}
key, err := iter.UnsafeEngineKey()
if err != nil {
fmt.Fprintf(b, "output: could not fetch key: %s\n", err)
return
}
ltKey, err := key.ToLockTableKey()
if err != nil {
fmt.Fprintf(b, "output: could not decode lock table key: %s\n", err)
return
}
v1, err := iter.UnsafeValue()
if err != nil {
fmt.Fprintf(b, "output: unable to fetch value: %s\n", err)
return
}
v2, err := iter.Value()
if err != nil {
fmt.Fprintf(b, "output: unable to fetch value: %s\n", err)
return
}
if !bytes.Equal(v1, v2) {
fmt.Fprintf(b, "output: value: %x != %x\n", v1, v2)
return
}
if len(v1) != iter.ValueLen() {
fmt.Fprintf(b, "output: value len: %d != %d\n", len(v1), iter.ValueLen())
return
}
var meta enginepb.MVCCMetadata
if err := protoutil.Unmarshal(v1, &meta); err != nil {
fmt.Fprintf(b, "output: meta parsing: %s\n", err)
return
}
if meta.Txn == nil {
fmt.Fprintf(b, "output: value txn empty\n")
return
}
if ltKey.TxnUUID != meta.Txn.ID {
fmt.Fprintf(b, "output: key txn id %v != value txn id %v\n", ltKey.TxnUUID, meta.Txn.ID)
return
}
fmt.Fprintf(b, "output: k=%s str=%s txn=%d\n",
string(ltKey.Key), strings.ToLower(ltKey.Strength.String()), ltKey.TxnUUID.ToUint128().Lo)
}
// TestLockTableIterator is a datadriven test consisting of two commands:
//
// - define: defines key-value pairs in the lock table through newline
// separated lock declarations:
//
// lock k=<key> str=<strength> txn=<txn>
//
// - iter: for iterating, is defined as:
//
// iter [lower=<lower>] [upper=<upper>] [prefix=<true|false>] [match-txn-id=<txn>] [match-min-str=<str>]
//
// followed by newline separated sequence of operations:
//
// seek-ge k=<key>
// seek-lt k=<key>
// seek-ge-with-limit k=<key> limit=<key>
// seek-lt-with-limit k=<key> limit=<key>
// next
// prev
// next-with-limit limit=<key>
// prev-with-limit limit=<key>
// stats
//
// Keys starting with "Gloabl/" are interpreted as global (not lock table) keys.
// Keys without this prefix are interpreted as lock table keys.
func TestLockTableIterator(t *testing.T) {
defer leaktest.AfterTest(t)()
defer log.Scope(t).Close(t)
var eng Engine
defer func() {
if eng != nil {
eng.Close()
}
}()
datadriven.Walk(t, datapathutils.TestDataPath(t, "lock_table_iterator"), func(t *testing.T, path string) {
datadriven.RunTest(t, path, func(t *testing.T, d *datadriven.TestData) string {
switch d.Cmd {
case "define":
if eng != nil {
eng.Close()
}
eng = createTestPebbleEngine()
batch := eng.NewBatch()
// pos is the original <file>:<lineno> prefix computed by
// datadriven. It points to the top "define" command itself.
// We are editing d.Pos in-place below by extending `pos` upon
// each new line.
pos := d.Pos
for i, line := range strings.Split(d.Input, "\n") {
// Compute a line prefix, to clarify error message. We
// prefix a newline character because some text editor do
// not know how to jump to the location of an error if
// there are multiple file:line prefixes on the same line.
d.Pos = fmt.Sprintf("\n%s: (+%d)", pos, i+1)
var err error
if d.Cmd, d.CmdArgs, err = datadriven.ParseLine(line); err != nil {
t.Fatalf("%s: %s", d.Pos, err)
}
switch d.Cmd {
case "lock":
key := scanRoachKey(t, d, "k")
str := scanLockStrength(t, d, "str")
txnID := scanTxnID(t, d, "txn")
ltKey := LockTableKey{Key: key, Strength: str, TxnUUID: txnID}
eKey, _ := ltKey.ToEngineKey(nil)
var ltVal enginepb.MVCCMetadata
ltVal.Txn = &enginepb.TxnMeta{ID: txnID}
val, err := protoutil.Marshal(<Val)
if err != nil {
t.Fatal(err)
}
if err := batch.PutEngineKey(eKey, val); err != nil {
t.Fatal(err)
}
default:
t.Fatalf("%s: unknown command %q", d.Pos, d.Cmd)
}
}
d.Pos = pos
if err := batch.Commit(true); err != nil {
t.Fatal(err)
}
return ""
case "iter":
var opts LockTableIteratorOptions
if d.HasArg("lower") {
opts.LowerBound = scanLockTableKey(t, d, "lower")
}
if d.HasArg("upper") {
opts.UpperBound = scanLockTableKey(t, d, "upper")
}
if d.HasArg("prefix") {
d.ScanArgs(t, "prefix", &opts.Prefix)
}
if d.HasArg("match-txn-id") {
opts.MatchTxnID = scanTxnID(t, d, "match-txn-id")
}
if d.HasArg("match-min-str") {
opts.MatchMinStr = scanLockStrength(t, d, "match-min-str")
}
iter, err := NewLockTableIterator(eng, opts)
if err != nil {
return fmt.Sprintf("error constructing new iter: %s", err)
}
defer iter.Close()
var b strings.Builder
// pos is the original <file>:<lineno> prefix computed by
// datadriven. It points to the top "define" command itself.
// We are editing d.Pos in-place below by extending `pos` upon
// each new line.
pos := d.Pos
for i, line := range strings.Split(d.Input, "\n") {
// Compute a line prefix, to clarify error message. We
// prefix a newline character because some text editor do
// not know how to jump to the location of an error if
// there are multiple file:line prefixes on the same line.
d.Pos = fmt.Sprintf("\n%s: (+%d)", pos, i+1)
var err error
if d.Cmd, d.CmdArgs, err = datadriven.ParseLine(line); err != nil {
t.Fatalf("%s: %s", d.Pos, err)
}
switch d.Cmd {
case "seek-ge":
key := scanLockTableKey(t, d, "k")
valid, err := iter.SeekEngineKeyGE(EngineKey{Key: key})
fmt.Fprintf(&b, "seek-ge k=%s: ", printLockTableKey(key))
checkAndOutputLockTableIterator(iter, &b, valid, err)
case "seek-lt":
key := scanLockTableKey(t, d, "k")
valid, err := iter.SeekEngineKeyLT(EngineKey{Key: key})
fmt.Fprintf(&b, "seek-lt k=%s: ", printLockTableKey(key))
checkAndOutputLockTableIterator(iter, &b, valid, err)
case "seek-ge-with-limit":
key := scanLockTableKey(t, d, "k")
limit := scanLockTableKey(t, d, "limit")
state, err := iter.SeekEngineKeyGEWithLimit(EngineKey{Key: key}, limit)
fmt.Fprintf(&b, "seek-ge-with-limit k=%s limit=%s: ",
printLockTableKey(key), printLockTableKey(limit))
checkAndOutputLockTableIteratorWithState(iter, &b, state, err)
case "seek-lt-with-limit":
key := scanLockTableKey(t, d, "k")
limit := scanLockTableKey(t, d, "limit")
state, err := iter.SeekEngineKeyLTWithLimit(EngineKey{Key: key}, limit)
fmt.Fprintf(&b, "seek-lt-with-limit k=%s limit=%s: ",
printLockTableKey(key), printLockTableKey(limit))
checkAndOutputLockTableIteratorWithState(iter, &b, state, err)
case "next":
valid, err := iter.NextEngineKey()
fmt.Fprintf(&b, "next: ")
checkAndOutputLockTableIterator(iter, &b, valid, err)
case "prev":
valid, err := iter.PrevEngineKey()
fmt.Fprintf(&b, "prev: ")
checkAndOutputLockTableIterator(iter, &b, valid, err)
case "next-with-limit":
limit := scanLockTableKey(t, d, "limit")
state, err := iter.NextEngineKeyWithLimit(limit)
fmt.Fprintf(&b, "next-with-limit limit=%s: ", printLockTableKey(limit))
checkAndOutputLockTableIteratorWithState(iter, &b, state, err)
case "prev-with-limit":
limit := scanLockTableKey(t, d, "limit")
state, err := iter.PrevEngineKeyWithLimit(limit)
fmt.Fprintf(&b, "prev-with-limit limit=%s: ", printLockTableKey(limit))
checkAndOutputLockTableIteratorWithState(iter, &b, state, err)
case "stats":
stats := iter.Stats()
// Setting non-deterministic InternalStats to empty.
stats.Stats.InternalStats = pebble.InternalIteratorStats{}
fmt.Fprintf(&b, "stats: %s\n", stats.Stats.String())
default:
t.Fatalf("%s: unknown command %q", d.Pos, d.Cmd)
}
}
d.Pos = pos
return b.String()
default:
t.Fatalf("%s: unknown command %q", d.Pos, d.Cmd)
return ""
}
})
})
}
// randKey is a random key.
type randKey []byte
func (randKey) generate(r *rand.Rand) randKey {
return randutil.RandBytes(r, 2)
}
func (k randKey) toRoachKey() roachpb.Key {
rk, _ := keys.LockTableSingleKey(roachpb.Key(k), nil)
return rk
}
func (k randKey) toEngineKey() EngineKey {
return EngineKey{Key: k.toRoachKey()}
}
// randLockStrength is a random lock strength.
type randLockStrength lock.Strength
func (randLockStrength) generate(r *rand.Rand) randLockStrength {
strs := []lock.Strength{lock.Shared, lock.Exclusive, lock.Intent}
return randLockStrength(strs[r.Intn(len(strs))])
}
func (s randLockStrength) toStr() lock.Strength {
return lock.Strength(s)
}
// randTxnID is a random transaction ID.
type randTxnID int
func (randTxnID) generate(r *rand.Rand) randTxnID {
return randTxnID(r.Intn(10) + 1)
}
func (id randTxnID) toUUID() uuid.UUID {
return uuid.FromUint128(uint128.FromInts(0, uint64(id)))
}
// randLockTableKey is a quick.Generator for lock table keys.
type randLockTableKey struct {
k randKey
s randLockStrength
t randTxnID
}
func (randLockTableKey) Generate(r *rand.Rand, size int) reflect.Value {
return reflect.ValueOf(randLockTableKey{
k: randKey{}.generate(r),
s: randLockStrength(0).generate(r),
t: randTxnID(0).generate(r),
})
}
func (k randLockTableKey) write(t *testing.T, w Writer) {
ltKey := LockTableKey{
Key: roachpb.Key(k.k),
Strength: k.s.toStr(),
TxnUUID: k.t.toUUID(),
}
eKey, _ := ltKey.ToEngineKey(nil)
var ltVal enginepb.MVCCMetadata
ltVal.Txn = &enginepb.TxnMeta{ID: ltKey.TxnUUID}
val, err := protoutil.Marshal(<Val)
require.NoError(t, err)
err = w.PutEngineKey(eKey, val)
require.NoError(t, err)
}
// randLockTableIterOpKind is a random LockTableIterator operation.
type randLockTableIterOpKind int
const (
lockTableIterOpKindSeekGE randLockTableIterOpKind = iota
lockTableIterOpKindSeekLT
lockTableIterOpKindSeekGEWithLimit
lockTableIterOpKindSeekLTWithLimit
lockTableIterOpKindNext
lockTableIterOpKindPrev
lockTableIterOpKindNextWithLimit
lockTableIterOpKindPrevWithLimit
numLockTableIterOpKinds
)
func (randLockTableIterOpKind) generate(r *rand.Rand) randLockTableIterOpKind {
return randLockTableIterOpKind(r.Intn(int(numLockTableIterOpKinds)))
}
// randLockTableIterOp is a quick.Generator for LockTableIterator operations.
type randLockTableIterOp struct {
op randLockTableIterOpKind
k randKey
limit randKey
}
func (randLockTableIterOp) Generate(r *rand.Rand, size int) reflect.Value {
return reflect.ValueOf(randLockTableIterOp{
op: randLockTableIterOpKind(0).generate(r),
k: randKey{}.generate(r),
limit: randKey{}.generate(r),
})
}
func (op randLockTableIterOp) apply(t *testing.T, iter EngineIterator, b *strings.Builder) {
printKeyValue := func() {
key, err := iter.UnsafeEngineKey()
require.NoError(t, err)
ltKey, err := key.ToLockTableKey()
require.NoError(t, err)
fmt.Fprintf(b, "k=%s str=%s txn=%s", string(ltKey.Key), ltKey.Strength, ltKey.TxnUUID)
}
printInvalid := func(err error) {
fmt.Fprintf(b, "valid=false err=%v", err)
}
switch op.op {
case lockTableIterOpKindSeekGE:
fmt.Fprintf(b, "seek-ge k=%s: ", op.k)
valid, err := iter.SeekEngineKeyGE(op.k.toEngineKey())
if !valid {
printInvalid(err)
} else {
printKeyValue()
}
case lockTableIterOpKindSeekLT:
fmt.Fprintf(b, "seek-lt k=%s: ", op.k)
valid, err := iter.SeekEngineKeyLT(op.k.toEngineKey())
if !valid {
printInvalid(err)
} else {
printKeyValue()
}
case lockTableIterOpKindSeekGEWithLimit:
fmt.Fprintf(b, "seek-ge-with-limit k=%s limit=%s: ", op.k, op.limit)
state, err := iter.SeekEngineKeyGEWithLimit(op.k.toEngineKey(), op.limit.toRoachKey())
if state != pebble.IterValid {
// NOTE: we don't distinguish between pebble.IterExhausted and
// pebble.IterAtLimit in this test, as the two are not always
// equivalent when filtering above an engine iterator vs. filtering
// before writing to the engine.
printInvalid(err)
} else {
printKeyValue()
}
case lockTableIterOpKindSeekLTWithLimit:
fmt.Fprintf(b, "seek-lt-with-limit k=%s limit=%s: ", op.k, op.limit)
state, err := iter.SeekEngineKeyLTWithLimit(op.k.toEngineKey(), op.limit.toRoachKey())
if state != pebble.IterValid {
printInvalid(err)
} else {
printKeyValue()
}
case lockTableIterOpKindNext:
fmt.Fprintf(b, "next: ")
valid, err := iter.NextEngineKey()
if !valid {
printInvalid(err)
} else {
printKeyValue()
}
case lockTableIterOpKindPrev:
fmt.Fprintf(b, "prev: ")
valid, err := iter.PrevEngineKey()
if !valid {
printInvalid(err)
} else {
printKeyValue()
}
case lockTableIterOpKindNextWithLimit:
fmt.Fprintf(b, "next-with-limit limit=%s ", op.limit)
state, err := iter.NextEngineKeyWithLimit(op.limit.toRoachKey())
if state != pebble.IterValid {
printInvalid(err)
} else {
printKeyValue()
}
case lockTableIterOpKindPrevWithLimit:
fmt.Fprintf(b, "prev-with-limit limit=%s ", op.limit)
state, err := iter.PrevEngineKeyWithLimit(op.limit.toRoachKey())
if state != pebble.IterValid {
printInvalid(err)
} else {
printKeyValue()
}
default:
panic("unreachable")
}
fmt.Fprint(b, "\n")
}
// randLockTableIterFilter is a quick.Generator for LockTableIterator filters.
type randLockTableIterFilter struct {
matchTxnID randTxnID
matchMinStr randLockStrength
}
func (randLockTableIterFilter) Generate(r *rand.Rand, size int) reflect.Value {
var filter randLockTableIterFilter
switch r.Intn(3) {
case 0:
// Match transaction ID.
filter.matchTxnID = randTxnID(0).generate(r)
case 1:
// Match minimum lock strength.
filter.matchMinStr = randLockStrength(0).generate(r)
case 2:
// Match both transaction ID and minimum lock strength.
filter.matchTxnID = randTxnID(0).generate(r)
filter.matchMinStr = randLockStrength(0).generate(r)
default:
panic("unreachable")
}
return reflect.ValueOf(filter)
}
func (f randLockTableIterFilter) filterKeys(keys []randLockTableKey) []randLockTableKey {
var res []randLockTableKey
for _, key := range keys {
matchTxnID := f.matchTxnID != 0 && f.matchTxnID == key.t
matchMinStr := f.matchMinStr != 0 && f.matchMinStr <= key.s
if matchTxnID || matchMinStr {
res = append(res, key)
}
}
return res
}
// TestLockTableIteratorEquivalence is a quickcheck test that verifies that a
// LockTableIterator is equivalent to a raw engine iterator with non-matching
// lock keys filtered before writing to the engine.
//
// The test does not avoid generating lock combinations that are not possible in
// the lock table in practice, like two exclusive locks held on the same key by
// different transactions. The LockTableIterator does not sufficiently benefit
// for making assumptions about lock compatibility, so we want to verify that it
// does not make any such assumptions.
func TestLockTableIteratorEquivalence(t *testing.T) {
defer leaktest.AfterTest(t)()
defer log.Scope(t).Close(t)
lockTableIter := func(ks []randLockTableKey, ops []randLockTableIterOp, f randLockTableIterFilter) string {
eng := createTestPebbleEngine()
defer eng.Close()
// Write all keys to the engine, without filtering.
for _, key := range ks {
key.write(t, eng)
}
// Then use a LockTableIterator with an appropriate filter config.
iter, err := NewLockTableIterator(eng, LockTableIteratorOptions{
UpperBound: keys.LockTableSingleKeyEnd,
MatchTxnID: f.matchTxnID.toUUID(),
MatchMinStr: f.matchMinStr.toStr(),
})
require.NoError(t, err)
defer iter.Close()
var b strings.Builder
for _, op := range ops {
op.apply(t, iter, &b)
}
return b.String()
}
preFilterIter := func(ks []randLockTableKey, ops []randLockTableIterOp, f randLockTableIterFilter) string {
eng := createTestPebbleEngine()
defer eng.Close()
// Filter the keys before writing them to the engine.
ks = f.filterKeys(ks)
for _, key := range ks {
key.write(t, eng)
}
// Then use a raw engine iterator.
iter, err := eng.NewEngineIterator(IterOptions{
UpperBound: keys.LockTableSingleKeyEnd,
})
require.NoError(t, err)
defer iter.Close()
var b strings.Builder
for _, op := range ops {
op.apply(t, iter, &b)
}
return b.String()
}
require.NoError(t, quick.CheckEqual(lockTableIter, preFilterIter, nil))
}