Skip to content

kvcoord: improve doc comment on mergeErrors #147493

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
12 changes: 6 additions & 6 deletions pkg/kv/kvclient/kvcoord/dist_sender.go
Original file line number Diff line number Diff line change
Expand Up @@ -1687,12 +1687,12 @@ func maybeSwapErrorIndex(pErr *kvpb.Error, a, b int) {
}
}

// mergeErrors merges the two errors, combining their transaction state and
// returning the error with the highest priority. If errors have the same
// priority, the error with the lowest request index is preferred. This allows
// a caller issuing multiple cputs to control which ConditionFailedError is
// returned. Specifically, it allows returning a primary key cput failure
// instead of a unique index conflict.
// mergeErrors merges two errors, combining their transaction states and
// returning the one with the higher priority. If priorities are equal, the
// error with the lower request index is preferred. This lets callers control
// which ConditionFailedError is returned when issuing multiple CPUTs. For
// example, SQL can guarantee a primary key CPUT failure instead of a unique
// index conflict by placing the primary key CPUT first in the batch.
func mergeErrors(pErr1, pErr2 *kvpb.Error) *kvpb.Error {
ret, drop := pErr1, pErr2

Expand Down