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

kvserver: ClearRange optimization does not remove separated intents #61606

Closed
erikgrinaker opened this issue Mar 8, 2021 · 0 comments · Fixed by #61649
Closed

kvserver: ClearRange optimization does not remove separated intents #61606

erikgrinaker opened this issue Mar 8, 2021 · 0 comments · Fixed by #61649
Assignees
Labels
A-kv-server Relating to the KV-level RPC server C-bug Code not up to spec/doc, specs & docs deemed correct. Solution expected to change code/behavior.

Comments

@erikgrinaker
Copy link
Contributor

erikgrinaker commented Mar 8, 2021

ClearRange normally uses Writer.ClearMVCCRangeAndIntents to remove the range, but has an optimization for small ranges where it instead removes keys directly:

// If the total size of data to be cleared is less than
// clearRangeBytesThreshold, clear the individual values manually,
// instead of using a range tombstone (inefficient for small ranges).
if total := statsDelta.Total(); total < ClearRangeBytesThreshold {
log.VEventf(ctx, 2, "delta=%d < threshold=%d; using non-range clear", total, ClearRangeBytesThreshold)
iter := readWriter.NewEngineIterator(storage.IterOptions{UpperBound: to})
valid, err := iter.SeekEngineKeyGE(storage.EngineKey{Key: from})
for ; valid; valid, err = iter.NextEngineKey() {
var k storage.EngineKey
if k, err = iter.UnsafeEngineKey(); err != nil {
break
}
if err = readWriter.ClearEngineKey(k); err != nil {
return result.Result{}, err
}
}
iter.Close()
if err != nil {
return result.Result{}, err
}
return pd, nil
}
if err := readWriter.ClearMVCCRangeAndIntents(from, to); err != nil {
return result.Result{}, err
}

However, when clusterversion.SeparatedIntents is enabled, this will only remove the key but not its intent (which is stored in a separate lock table). This can cause subsequent Engine operations to error because of the unexpected intent, as seen e.g. in TestTxnClearRangeIntents in #61544.

This is related to #46764, in that clearing intents may in itself be considered a bug since it can abort an implicitly committed transaction.

@erikgrinaker erikgrinaker added C-bug Code not up to spec/doc, specs & docs deemed correct. Solution expected to change code/behavior. A-kv-server Relating to the KV-level RPC server labels Mar 8, 2021
@erikgrinaker erikgrinaker self-assigned this Mar 8, 2021
@craig craig bot closed this as completed in 1a6fdd3 Mar 9, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-kv-server Relating to the KV-level RPC server C-bug Code not up to spec/doc, specs & docs deemed correct. Solution expected to change code/behavior.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant