@@ -373,16 +373,15 @@ type Replica struct {
373373 minLeaseProposedTS hlc.Timestamp
374374 // Max bytes before split.
375375 maxBytes int64
376- // proposals stores the Raft in-flight commands which
377- // originated at this Replica, i.e. all commands for which
378- // propose has been called, but which have not yet
379- // applied.
376+ // localProposals stores the Raft in-flight commands which originated at
377+ // this Replica, i.e. all commands for which propose has been called,
378+ // but which have not yet applied.
380379 //
381380 // The *ProposalData in the map are "owned" by it. Elements from the
382381 // map must only be referenced while Replica.mu is held, except if the
383382 // element is removed from the map first. The notable exception is the
384383 // contained RaftCommand, which we treat as immutable.
385- proposals map [storagebase.CmdIDKey ]* ProposalData
384+ localProposals map [storagebase.CmdIDKey ]* ProposalData
386385 // remoteProposals is maintained by Raft leaders and stores in-flight
387386 // commands that were forwarded to the leader during its current term.
388387 // The set allows leaders to detect duplicate forwarded commands and
@@ -696,7 +695,7 @@ func (r *Replica) initRaftMuLockedReplicaMuLocked(
696695 r .cmdQMu .queues [spanset .SpanLocal ] = NewCommandQueue (false /* optimizeOverlap */ )
697696 r .cmdQMu .Unlock ()
698697
699- r .mu .proposals = map [storagebase.CmdIDKey ]* ProposalData {}
698+ r .mu .localProposals = map [storagebase.CmdIDKey ]* ProposalData {}
700699 r .mu .checksums = map [uuid.UUID ]ReplicaChecksum {}
701700 // Clear the internal raft group in case we're being reset. Since we're
702701 // reloading the raft state below, it isn't safe to use the existing raft
@@ -852,7 +851,7 @@ func (r *Replica) cancelPendingCommandsLocked() {
852851 Err : roachpb .NewError (roachpb .NewAmbiguousResultError ("removing replica" )),
853852 ProposalRetry : proposalRangeNoLongerExists ,
854853 }
855- for _ , p := range r .mu .proposals {
854+ for _ , p := range r .mu .localProposals {
856855 r .cleanupFailedProposalLocked (p )
857856 p .finishApplication (pr )
858857 }
@@ -864,7 +863,7 @@ func (r *Replica) cancelPendingCommandsLocked() {
864863func (r * Replica ) cleanupFailedProposalLocked (p * ProposalData ) {
865864 // Clear the proposal from the proposals map. May be a no-op if the
866865 // proposal has not yet been inserted into the map.
867- delete (r .mu .proposals , p .idKey )
866+ delete (r .mu .localProposals , p .idKey )
868867 // Release associated quota pool resources if we have been tracking
869868 // this command.
870869 //
@@ -1866,7 +1865,7 @@ func (r *Replica) State() storagebase.RangeInfo {
18661865 var ri storagebase.RangeInfo
18671866 ri .ReplicaState = * (protoutil .Clone (& r .mu .state )).(* storagebase.ReplicaState )
18681867 ri .LastIndex = r .mu .lastIndex
1869- ri .NumPending = uint64 (len (r .mu .proposals ))
1868+ ri .NumPending = uint64 (len (r .mu .localProposals ))
18701869 ri .RaftLogSize = r .mu .raftLogSize
18711870 ri .NumDropped = uint64 (r .mu .droppedMessages )
18721871 if r .mu .proposalQuota != nil {
@@ -3344,11 +3343,11 @@ func (r *Replica) insertProposalLocked(
33443343 proposal .idKey , proposal .command .MaxLeaseIndex )
33453344 }
33463345
3347- if _ , ok := r .mu .proposals [proposal .idKey ]; ok {
3346+ if _ , ok := r .mu .localProposals [proposal .idKey ]; ok {
33483347 ctx := r .AnnotateCtx (context .TODO ())
33493348 log .Fatalf (ctx , "pending command already exists for %s" , proposal .idKey )
33503349 }
3351- r .mu .proposals [proposal .idKey ] = proposal
3350+ r .mu .localProposals [proposal .idKey ] = proposal
33523351}
33533352
33543353func makeIDKey () storagebase.CmdIDKey {
@@ -3556,7 +3555,7 @@ func (r *Replica) propose(
35563555 // range.
35573556 tryAbandon := func () bool {
35583557 r .mu .Lock ()
3559- p , ok := r .mu .proposals [idKey ]
3558+ p , ok := r .mu .localProposals [idKey ]
35603559 if ok {
35613560 // TODO(radu): Should this context be created via tracer.ForkCtxSpan?
35623561 // We'd need to make sure the span is finished eventually.
@@ -3683,9 +3682,9 @@ func (r *Replica) quiesce() bool {
36833682
36843683func (r * Replica ) quiesceLocked () bool {
36853684 ctx := r .AnnotateCtx (context .TODO ())
3686- if len (r .mu .proposals ) != 0 {
3685+ if len (r .mu .localProposals ) != 0 {
36873686 if log .V (3 ) {
3688- log .Infof (ctx , "not quiescing: %d pending commands" , len (r .mu .proposals ))
3687+ log .Infof (ctx , "not quiescing: %d pending commands" , len (r .mu .localProposals ))
36893688 }
36903689 return false
36913690 }
@@ -4339,7 +4338,7 @@ func (r *Replica) tick(livenessMap map[roachpb.NodeID]bool) (bool, error) {
43394338// correctness issues.
43404339func (r * Replica ) maybeQuiesceLocked (livenessMap map [roachpb.NodeID ]bool ) bool {
43414340 ctx := r .AnnotateCtx (context .TODO ())
4342- status , ok := shouldReplicaQuiesce (ctx , r , r .store .Clock ().Now (), len (r .mu .proposals ), livenessMap )
4341+ status , ok := shouldReplicaQuiesce (ctx , r , r .store .Clock ().Now (), len (r .mu .localProposals ), livenessMap )
43434342 if ! ok {
43444343 return false
43454344 }
@@ -4600,7 +4599,7 @@ func (r *Replica) refreshProposalsLocked(refreshAtDelta int, reason refreshRaftR
46004599
46014600 numShouldRetry := 0
46024601 var reproposals pendingCmdSlice
4603- for _ , p := range r .mu .proposals {
4602+ for _ , p := range r .mu .localProposals {
46044603 if p .command .MaxLeaseIndex == 0 {
46054604 // Commands without a MaxLeaseIndex cannot be reproposed, as they might
46064605 // apply twice. We also don't want to ask the proposer to retry these
@@ -5070,14 +5069,14 @@ func (r *Replica) processRaftCommand(
50705069 }
50715070
50725071 r .mu .Lock ()
5073- proposal , proposedLocally := r .mu .proposals [idKey ]
5072+ proposal , proposedLocally := r .mu .localProposals [idKey ]
50745073
50755074 // TODO(tschottdorf): consider the Trace situation here.
50765075 if proposedLocally {
50775076 // We initiated this command, so use the caller-supplied context.
50785077 ctx = proposal .ctx
50795078 proposal .ctx = nil // avoid confusion
5080- delete (r .mu .proposals , idKey )
5079+ delete (r .mu .localProposals , idKey )
50815080 }
50825081
50835082 // Delete the entry for a forwarded proposal set.
0 commit comments