Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

storage/metamorphic: Add MVCC delete range using tombstone #83945

Merged
merged 1 commit into from
Jul 7, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pkg/storage/metamorphic/generator.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ func (e *engineConfig) String() string {
return e.name
}

var engineConfigStandard = engineConfig{"standard=0", storage.DefaultPebbleOptions()}
var engineConfigStandard = engineConfig{"standard=0", standardOptions(0)}

type engineSequence struct {
name string
Expand Down
53 changes: 52 additions & 1 deletion pkg/storage/metamorphic/operations.go
Original file line number Diff line number Diff line change
Expand Up @@ -300,6 +300,30 @@ func (m mvccDeleteRangeOp) run(ctx context.Context) string {
return builder.String()
}

type mvccDeleteRangeUsingRangeTombstoneOp struct {
m *metaTestRunner
writer readWriterID
key roachpb.Key
endKey roachpb.Key
ts hlc.Timestamp
}

func (m mvccDeleteRangeUsingRangeTombstoneOp) run(ctx context.Context) string {
writer := m.m.getReadWriter(m.writer)
if m.key.Compare(m.endKey) >= 0 {
// Empty range. No-op.
return "no-op due to no non-conflicting key range"
}

err := storage.MVCCDeleteRangeUsingTombstone(ctx, writer, nil, m.key, m.endKey,
m.ts, hlc.ClockTimestamp{}, m.key, m.endKey, math.MaxInt64 /* maxIntents */)
if err != nil {
return fmt.Sprintf("error: %s", err)
}

return fmt.Sprintf("deleted range = %s - %s", m.key, m.endKey)
}

type mvccClearTimeRangeOp struct {
m *metaTestRunner
key roachpb.Key
Expand Down Expand Up @@ -923,7 +947,34 @@ var opGenerators = []opGenerator{
operandUnusedMVCCKey,
operandUnusedMVCCKey,
},
weight: 20,
weight: 10,
},
{
name: "mvcc_delete_range_using_range_tombstone",
generate: func(ctx context.Context, m *metaTestRunner, args ...string) mvccOp {
writer := readWriterID(args[0])
key := m.keyGenerator.parse(args[1]).Key
endKey := m.keyGenerator.parse(args[2]).Key
ts := m.nextTSGenerator.parse(args[3])

if endKey.Compare(key) < 0 {
key, endKey = endKey, key
}
return &mvccDeleteRangeUsingRangeTombstoneOp{
m: m,
writer: writer,
key: key,
endKey: endKey,
ts: ts,
}
},
operands: []operandType{
operandReadWriter,
operandMVCCKey,
operandMVCCKey,
operandNextTS,
},
weight: 10,
},
{
name: "mvcc_clear_time_range",
Expand Down
4 changes: 4 additions & 0 deletions pkg/storage/metamorphic/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,11 +100,15 @@ func standardOptions(i int) *pebble.Options {
if err := opts.Parse(stdOpts[i], nil); err != nil {
panic(err)
}
// Enable range keys in all options.
opts.FormatMajorVersion = pebble.FormatRangeKeys
return opts
}

func randomOptions() *pebble.Options {
opts := storage.DefaultPebbleOptions()
// Enable range keys in all options.
opts.FormatMajorVersion = pebble.FormatRangeKeys

rng, _ := randutil.NewTestRand()
opts.BytesPerSync = 1 << rngIntRange(rng, 8, 30)
Expand Down