Skip to content

Commit

Permalink
kvserver: improve some closedts comments
Browse files Browse the repository at this point in the history
Release note: None
  • Loading branch information
andreimatei committed May 26, 2021
1 parent 70b13ab commit 128c1e6
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions pkg/kv/kvserver/replica_proposal_buf.go
Original file line number Diff line number Diff line change
Expand Up @@ -692,10 +692,16 @@ func (b *propBuf) FlushLockedWithRaftGroup(
return used, proposeBatch(raftGroup, b.p.replicaID(), ents)
}

// assignClosedTimestampToProposalLocked assigns a closed timestamp to be carried by
// an outgoing proposal.
// assignClosedTimestampToProposalLocked assigns a closed timestamp to be
// carried by an outgoing proposal, modifying p.encodedCommand. closedTSTarget
// is the timestamp that should be closed for this range according to the
// range's closing policy. This function will look at the particularities of
// the range and of the proposal and decide to close a different timestamp.
//
// This shouldn't be called for reproposals.
// This shouldn't be called for reproposals; we don't want to update the closed
// timestamp they carry (we could, in principle, but we'd have to make a copy of
// the encoded command as to not modify the copy that's already stored in the
// local replica's raft entry cache).
func (b *propBuf) assignClosedTimestampToProposalLocked(
ctx context.Context, p *ProposalData, closedTSTarget hlc.Timestamp,
) error {
Expand All @@ -717,9 +723,10 @@ func (b *propBuf) assignClosedTimestampToProposalLocked(
// commute and both apply which would result in a closed timestamp regression.
// The command application side doesn't bother protecting against such
// regressions.
// Lease transfers behave like regular proposals. Note that transfers
// carry a summary of the timestamp cache, so the new leaseholder will be
// aware of all the reads performed by the previous leaseholder.
// Lease transfers behave like regular proposals - they get a closed timestamp
// based on closedTSTarget. Note that transfers carry a summary of the
// timestamp cache, so the new leaseholder will be aware of all the reads
// performed by the previous leaseholder.
if p.Request.IsLeaseRequest() {
// We read the lease from the ReplicatedEvalResult, not from leaseReq, because the
// former is more up to date, having been modified by the evaluation.
Expand Down

0 comments on commit 128c1e6

Please sign in to comment.