Skip to content

Commit 848fd26

Browse files
committed
kv: clarify return value on EndTxnResponse
Addresses a TODO from the last commit. Epic: none Release note: None
1 parent 59f92fe commit 848fd26

File tree

3 files changed

+23
-19
lines changed

3 files changed

+23
-19
lines changed

pkg/kv/kvpb/api.proto

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1027,18 +1027,24 @@ message EndTxnResponse {
10271027
// The commit timestamp of the STAGING transaction record written
10281028
// by the request. Only set if the transaction record was staged.
10291029
util.hlc.Timestamp staging_timestamp = 5 [(gogoproto.nullable) = false];
1030-
// ReplicatedLocksReleasedOnCommit, if non-empty, indicate that replicated
1031-
// locks with strength Shared or Exclusive were released in the referenced key
1032-
// spans when committing this transaction. Notably, this field is left unset
1033-
// if only write intents were resolved. The field is also left unset for
1034-
// transactions that aborted.
1030+
// ReplicatedLocalLocksReleasedOnCommit, if non-empty, indicate that
1031+
// replicated locks with strength Shared or Exclusive were released in the
1032+
// referenced key spans when committing this transaction. These locks are
1033+
// local to the range on which the EndTxn request evaluated. Notably, this
1034+
// field is left unset if only write intents were resolved. The field is only
1035+
// set when transactions are explicitly marked as committed.
10351036
//
10361037
// The caller must bump the timestamp cache across these spans to the
1037-
// transaction's commit timestamp. Doing so ensures that the released locks
1038-
// (acquired by the now committed transaction) continue to provide protection
1039-
// against other writers up to the commit timestamp, even after the locks have
1040-
// been released.
1041-
repeated Span replicated_locks_released_on_commit = 6 [(gogoproto.nullable) = false];
1038+
// transaction's commit timestamp. Doing so ensures that the released local[1]
1039+
// locks (acquired by the now committed transaction) continue to provide
1040+
// protection against other writers up to the commit timestamp, even after the
1041+
// locks have been released.
1042+
//
1043+
// [1] Non-local replicated locks provide the same protection, however, the
1044+
// mechanism of bumping the timestamp cache is different there. See the
1045+
// ReplicatedLocksReleasedCommitTimestamp field on
1046+
// ResolveIntent{,Range}Response.
1047+
repeated Span replicated_local_locks_released_on_commit = 6 [(gogoproto.nullable) = false];
10421048
}
10431049

10441050
// An AdminSplitRequest is the argument to the AdminSplit() method. The

pkg/kv/kvserver/batcheval/cmd_end_transaction.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -560,9 +560,7 @@ func EndTxn(
560560
// transaction's commit timestamp to the key spans previously protected by
561561
// the locks. We return the spans on the response and update the timestamp
562562
// cache a few layers above to ensure this.
563-
//
564-
// TODO(arul): rename this to include the word local in it.
565-
reply.ReplicatedLocksReleasedOnCommit = releasedReplLocks
563+
reply.ReplicatedLocalLocksReleasedOnCommit = releasedReplLocks
566564
log.VEventf(
567565
ctx, 2, "committed transaction released local replicated shared/exclusive locks",
568566
)

pkg/kv/kvserver/replica_tscache.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -170,12 +170,12 @@ func (r *Replica) updateTimestampCache(
170170
// transaction's MinTimestamp, which is consulted in CanCreateTxnRecord.
171171
key := transactionTombstoneMarker(start, txnID)
172172
addToTSCache(key, nil, ts, txnID)
173-
// Additionally, EndTxn requests that release replicated locks for
174-
// committed transactions bump the timestamp cache over those lock
175-
// spans to the commit timestamp of the transaction to ensure that
176-
// the released locks continue to provide protection against writes
177-
// underneath the transaction's commit timestamp.
178-
for _, sp := range resp.(*kvpb.EndTxnResponse).ReplicatedLocksReleasedOnCommit {
173+
// Additionally, EndTxn requests that release local replicated locks for
174+
// committed transactions bump the timestamp cache over those lock spans
175+
// to the commit timestamp of the transaction to ensure that the released
176+
// locks continue to provide protection against writes underneath the
177+
// transaction's commit timestamp.
178+
for _, sp := range resp.(*kvpb.EndTxnResponse).ReplicatedLocalLocksReleasedOnCommit {
179179
addToTSCache(sp.Key, sp.EndKey, br.Txn.WriteTimestamp, txnID)
180180
}
181181
case *kvpb.HeartbeatTxnRequest:

0 commit comments

Comments
 (0)