@@ -373,16 +373,15 @@ type Replica struct {
373
373
minLeaseProposedTS hlc.Timestamp
374
374
// Max bytes before split.
375
375
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.
380
379
//
381
380
// The *ProposalData in the map are "owned" by it. Elements from the
382
381
// map must only be referenced while Replica.mu is held, except if the
383
382
// element is removed from the map first. The notable exception is the
384
383
// contained RaftCommand, which we treat as immutable.
385
- proposals map [storagebase.CmdIDKey ]* ProposalData
384
+ localProposals map [storagebase.CmdIDKey ]* ProposalData
386
385
// remoteProposals is maintained by Raft leaders and stores in-flight
387
386
// commands that were forwarded to the leader during its current term.
388
387
// The set allows leaders to detect duplicate forwarded commands and
@@ -696,7 +695,7 @@ func (r *Replica) initRaftMuLockedReplicaMuLocked(
696
695
r .cmdQMu .queues [spanset .SpanLocal ] = NewCommandQueue (false /* optimizeOverlap */ )
697
696
r .cmdQMu .Unlock ()
698
697
699
- r .mu .proposals = map [storagebase.CmdIDKey ]* ProposalData {}
698
+ r .mu .localProposals = map [storagebase.CmdIDKey ]* ProposalData {}
700
699
r .mu .checksums = map [uuid.UUID ]ReplicaChecksum {}
701
700
// Clear the internal raft group in case we're being reset. Since we're
702
701
// reloading the raft state below, it isn't safe to use the existing raft
@@ -852,7 +851,7 @@ func (r *Replica) cancelPendingCommandsLocked() {
852
851
Err : roachpb .NewError (roachpb .NewAmbiguousResultError ("removing replica" )),
853
852
ProposalRetry : proposalRangeNoLongerExists ,
854
853
}
855
- for _ , p := range r .mu .proposals {
854
+ for _ , p := range r .mu .localProposals {
856
855
r .cleanupFailedProposalLocked (p )
857
856
p .finishApplication (pr )
858
857
}
@@ -864,7 +863,7 @@ func (r *Replica) cancelPendingCommandsLocked() {
864
863
func (r * Replica ) cleanupFailedProposalLocked (p * ProposalData ) {
865
864
// Clear the proposal from the proposals map. May be a no-op if the
866
865
// proposal has not yet been inserted into the map.
867
- delete (r .mu .proposals , p .idKey )
866
+ delete (r .mu .localProposals , p .idKey )
868
867
// Release associated quota pool resources if we have been tracking
869
868
// this command.
870
869
//
@@ -1866,7 +1865,7 @@ func (r *Replica) State() storagebase.RangeInfo {
1866
1865
var ri storagebase.RangeInfo
1867
1866
ri .ReplicaState = * (protoutil .Clone (& r .mu .state )).(* storagebase.ReplicaState )
1868
1867
ri .LastIndex = r .mu .lastIndex
1869
- ri .NumPending = uint64 (len (r .mu .proposals ))
1868
+ ri .NumPending = uint64 (len (r .mu .localProposals ))
1870
1869
ri .RaftLogSize = r .mu .raftLogSize
1871
1870
ri .NumDropped = uint64 (r .mu .droppedMessages )
1872
1871
if r .mu .proposalQuota != nil {
@@ -3344,11 +3343,11 @@ func (r *Replica) insertProposalLocked(
3344
3343
proposal .idKey , proposal .command .MaxLeaseIndex )
3345
3344
}
3346
3345
3347
- if _ , ok := r .mu .proposals [proposal .idKey ]; ok {
3346
+ if _ , ok := r .mu .localProposals [proposal .idKey ]; ok {
3348
3347
ctx := r .AnnotateCtx (context .TODO ())
3349
3348
log .Fatalf (ctx , "pending command already exists for %s" , proposal .idKey )
3350
3349
}
3351
- r .mu .proposals [proposal .idKey ] = proposal
3350
+ r .mu .localProposals [proposal .idKey ] = proposal
3352
3351
}
3353
3352
3354
3353
func makeIDKey () storagebase.CmdIDKey {
@@ -3556,7 +3555,7 @@ func (r *Replica) propose(
3556
3555
// range.
3557
3556
tryAbandon := func () bool {
3558
3557
r .mu .Lock ()
3559
- p , ok := r .mu .proposals [idKey ]
3558
+ p , ok := r .mu .localProposals [idKey ]
3560
3559
if ok {
3561
3560
// TODO(radu): Should this context be created via tracer.ForkCtxSpan?
3562
3561
// We'd need to make sure the span is finished eventually.
@@ -3683,9 +3682,9 @@ func (r *Replica) quiesce() bool {
3683
3682
3684
3683
func (r * Replica ) quiesceLocked () bool {
3685
3684
ctx := r .AnnotateCtx (context .TODO ())
3686
- if len (r .mu .proposals ) != 0 {
3685
+ if len (r .mu .localProposals ) != 0 {
3687
3686
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 ))
3689
3688
}
3690
3689
return false
3691
3690
}
@@ -4339,7 +4338,7 @@ func (r *Replica) tick(livenessMap map[roachpb.NodeID]bool) (bool, error) {
4339
4338
// correctness issues.
4340
4339
func (r * Replica ) maybeQuiesceLocked (livenessMap map [roachpb.NodeID ]bool ) bool {
4341
4340
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 )
4343
4342
if ! ok {
4344
4343
return false
4345
4344
}
@@ -4600,7 +4599,7 @@ func (r *Replica) refreshProposalsLocked(refreshAtDelta int, reason refreshRaftR
4600
4599
4601
4600
numShouldRetry := 0
4602
4601
var reproposals pendingCmdSlice
4603
- for _ , p := range r .mu .proposals {
4602
+ for _ , p := range r .mu .localProposals {
4604
4603
if p .command .MaxLeaseIndex == 0 {
4605
4604
// Commands without a MaxLeaseIndex cannot be reproposed, as they might
4606
4605
// apply twice. We also don't want to ask the proposer to retry these
@@ -5070,14 +5069,14 @@ func (r *Replica) processRaftCommand(
5070
5069
}
5071
5070
5072
5071
r .mu .Lock ()
5073
- proposal , proposedLocally := r .mu .proposals [idKey ]
5072
+ proposal , proposedLocally := r .mu .localProposals [idKey ]
5074
5073
5075
5074
// TODO(tschottdorf): consider the Trace situation here.
5076
5075
if proposedLocally {
5077
5076
// We initiated this command, so use the caller-supplied context.
5078
5077
ctx = proposal .ctx
5079
5078
proposal .ctx = nil // avoid confusion
5080
- delete (r .mu .proposals , idKey )
5079
+ delete (r .mu .localProposals , idKey )
5081
5080
}
5082
5081
5083
5082
// Delete the entry for a forwarded proposal set.
0 commit comments