Skip to content

Commit 6f5cc54

Browse files
storage: s/replica.mu.proposals/replica.mu.localProposals/
The reverse of 192a828. Release note: None
1 parent 58413cb commit 6f5cc54

File tree

3 files changed

+26
-26
lines changed

3 files changed

+26
-26
lines changed

pkg/storage/replica.go

+20-20
Original file line numberDiff line numberDiff line change
@@ -379,15 +379,15 @@ type Replica struct {
379379
minLeaseProposedTS hlc.Timestamp
380380
// A pointer to the zone config for this replica.
381381
zone *config.ZoneConfig
382-
// localProposals stores the Raft in-flight commands which originated at
382+
// proposals stores the Raft in-flight commands which originated at
383383
// this Replica, i.e. all commands for which propose has been called,
384384
// but which have not yet applied.
385385
//
386386
// The *ProposalData in the map are "owned" by it. Elements from the
387387
// map must only be referenced while Replica.mu is held, except if the
388388
// element is removed from the map first. The notable exception is the
389389
// contained RaftCommand, which we treat as immutable.
390-
localProposals map[storagebase.CmdIDKey]*ProposalData
390+
proposals map[storagebase.CmdIDKey]*ProposalData
391391
internalRaftGroup *raft.RawNode
392392
// The ID of the replica within the Raft group. May be 0 if the replica has
393393
// been created from a preemptive snapshot (i.e. before being added to the
@@ -703,7 +703,7 @@ func (r *Replica) initRaftMuLockedReplicaMuLocked(
703703
r.cmdQMu.queues[spanset.SpanLocal] = NewCommandQueue(false /* optimizeOverlap */)
704704
r.cmdQMu.Unlock()
705705

706-
r.mu.localProposals = map[storagebase.CmdIDKey]*ProposalData{}
706+
r.mu.proposals = map[storagebase.CmdIDKey]*ProposalData{}
707707
r.mu.checksums = map[uuid.UUID]ReplicaChecksum{}
708708
// Clear the internal raft group in case we're being reset. Since we're
709709
// reloading the raft state below, it isn't safe to use the existing raft
@@ -874,7 +874,7 @@ func (r *Replica) cancelPendingCommandsLocked() {
874874
Err: roachpb.NewError(roachpb.NewAmbiguousResultError("removing replica")),
875875
ProposalRetry: proposalRangeNoLongerExists,
876876
}
877-
for _, p := range r.mu.localProposals {
877+
for _, p := range r.mu.proposals {
878878
r.cleanupFailedProposalLocked(p)
879879
p.finishApplication(pr)
880880
}
@@ -885,7 +885,7 @@ func (r *Replica) cancelPendingCommandsLocked() {
885885
func (r *Replica) cleanupFailedProposalLocked(p *ProposalData) {
886886
// Clear the proposal from the proposals map. May be a no-op if the
887887
// proposal has not yet been inserted into the map.
888-
delete(r.mu.localProposals, p.idKey)
888+
delete(r.mu.proposals, p.idKey)
889889
// Release associated quota pool resources if we have been tracking
890890
// this command.
891891
//
@@ -1896,7 +1896,7 @@ func (r *Replica) State() storagepb.RangeInfo {
18961896
var ri storagepb.RangeInfo
18971897
ri.ReplicaState = *(protoutil.Clone(&r.mu.state)).(*storagepb.ReplicaState)
18981898
ri.LastIndex = r.mu.lastIndex
1899-
ri.NumPending = uint64(len(r.mu.localProposals))
1899+
ri.NumPending = uint64(len(r.mu.proposals))
19001900
ri.RaftLogSize = r.mu.raftLogSize
19011901
ri.NumDropped = uint64(r.mu.droppedMessages)
19021902
if r.mu.proposalQuota != nil {
@@ -3584,11 +3584,11 @@ func (r *Replica) insertProposalLocked(
35843584
proposal.idKey, proposal.command.MaxLeaseIndex)
35853585
}
35863586

3587-
if _, ok := r.mu.localProposals[proposal.idKey]; ok {
3587+
if _, ok := r.mu.proposals[proposal.idKey]; ok {
35883588
ctx := r.AnnotateCtx(context.TODO())
35893589
log.Fatalf(ctx, "pending command already exists for %s", proposal.idKey)
35903590
}
3591-
r.mu.localProposals[proposal.idKey] = proposal
3591+
r.mu.proposals[proposal.idKey] = proposal
35923592
if isLease {
35933593
// For lease requests, we return zero because no real MaxLeaseIndex is assigned.
35943594
// We could also return the lastAssignedIndex but this invites confusion.
@@ -3812,7 +3812,7 @@ func (r *Replica) propose(
38123812
}
38133813

38143814
// Must not use `proposal` in the closure below as a proposal which is not
3815-
// present in r.mu.localProposals is no longer protected by the mutex. Abandoning
3815+
// present in r.mu.proposals is no longer protected by the mutex. Abandoning
38163816
// a command only abandons the associated context. As soon as we propose a
38173817
// command to Raft, ownership passes to the "below Raft" machinery. In
38183818
// particular, endCmds will be invoked when the command is applied. There are
@@ -3821,7 +3821,7 @@ func (r *Replica) propose(
38213821
// range.
38223822
tryAbandon := func() bool {
38233823
r.mu.Lock()
3824-
p, ok := r.mu.localProposals[idKey]
3824+
p, ok := r.mu.proposals[idKey]
38253825
if ok {
38263826
// TODO(radu): Should this context be created via tracer.ForkCtxSpan?
38273827
// We'd need to make sure the span is finished eventually.
@@ -3833,7 +3833,7 @@ func (r *Replica) propose(
38333833
return proposalCh, tryAbandon, maxLeaseIndex, nil
38343834
}
38353835

3836-
// submitProposalLocked proposes or re-proposes a command in r.mu.localProposals.
3836+
// submitProposalLocked proposes or re-proposes a command in r.mu.proposals.
38373837
// The replica lock must be held.
38383838
func (r *Replica) submitProposalLocked(p *ProposalData) error {
38393839
p.proposedAtTicks = r.mu.ticks
@@ -3948,9 +3948,9 @@ func (r *Replica) quiesce() bool {
39483948

39493949
func (r *Replica) quiesceLocked() bool {
39503950
ctx := r.AnnotateCtx(context.TODO())
3951-
if len(r.mu.localProposals) != 0 {
3951+
if len(r.mu.proposals) != 0 {
39523952
if log.V(3) {
3953-
log.Infof(ctx, "not quiescing: %d pending commands", len(r.mu.localProposals))
3953+
log.Infof(ctx, "not quiescing: %d pending commands", len(r.mu.proposals))
39543954
}
39553955
return false
39563956
}
@@ -4577,7 +4577,7 @@ func (r *Replica) tick(livenessMap IsLiveMap) (bool, error) {
45774577
// correctness issues.
45784578
func (r *Replica) maybeQuiesceLocked(livenessMap IsLiveMap) bool {
45794579
ctx := r.AnnotateCtx(context.TODO())
4580-
status, ok := shouldReplicaQuiesce(ctx, r, r.store.Clock().Now(), len(r.mu.localProposals), livenessMap)
4580+
status, ok := shouldReplicaQuiesce(ctx, r, r.store.Clock().Now(), len(r.mu.proposals), livenessMap)
45814581
if !ok {
45824582
return false
45834583
}
@@ -4828,7 +4828,7 @@ func (r *Replica) refreshProposalsLocked(refreshAtDelta int, reason refreshRaftR
48284828

48294829
numShouldRetry := 0
48304830
var reproposals pendingCmdSlice
4831-
for _, p := range r.mu.localProposals {
4831+
for _, p := range r.mu.proposals {
48324832
if p.command.MaxLeaseIndex == 0 {
48334833
// Commands without a MaxLeaseIndex cannot be reproposed, as they might
48344834
// apply twice. We also don't want to ask the proposer to retry these
@@ -4843,7 +4843,7 @@ func (r *Replica) refreshProposalsLocked(refreshAtDelta int, reason refreshRaftR
48434843
} else if cannotApplyAnyMore := !p.command.ReplicatedEvalResult.IsLeaseRequest &&
48444844
p.command.MaxLeaseIndex <= r.mu.state.LeaseAppliedIndex; cannotApplyAnyMore {
48454845
// The command's designated lease index slot was filled up. We got to
4846-
// LeaseAppliedIndex and p is still pending in r.mu.localProposals; generally
4846+
// LeaseAppliedIndex and p is still pending in r.mu.proposals; generally
48474847
// this means that proposal p didn't commit, and it will be sent back to
48484848
// the proposer for a retry - the request needs to be re-evaluated and the
48494849
// command re-proposed with a new MaxLeaseIndex. Note that this branch is not
@@ -4854,7 +4854,7 @@ func (r *Replica) refreshProposalsLocked(refreshAtDelta int, reason refreshRaftR
48544854
// reasonSnapshotApplied - in that case we don't know if p or some other
48554855
// command filled the p.command.MaxLeaseIndex slot (i.e. p might have been
48564856
// applied, but we're not watching for every proposal when applying a
4857-
// snapshot, so nobody removed p from r.mu.localProposals). In this
4857+
// snapshot, so nobody removed p from r.mu.proposals). In this
48584858
// ambiguous case, we'll also send the command back to the proposer for a
48594859
// retry, but the proposer needs to be aware that, if the retry fails, an
48604860
// AmbiguousResultError needs to be returned to the higher layers.
@@ -4915,7 +4915,7 @@ func (r *Replica) refreshProposalsLocked(refreshAtDelta int, reason refreshRaftR
49154915
// that they can make it in the right place. Reproposing in order is
49164916
// definitely required, however.
49174917
//
4918-
// TODO(tschottdorf): evaluate whether `r.mu.localProposals` should
4918+
// TODO(tschottdorf): evaluate whether `r.mu.proposals` should
49194919
// be a list/slice.
49204920
sort.Sort(reproposals)
49214921
for _, p := range reproposals {
@@ -5295,14 +5295,14 @@ func (r *Replica) processRaftCommand(
52955295
}
52965296

52975297
r.mu.Lock()
5298-
proposal, proposedLocally := r.mu.localProposals[idKey]
5298+
proposal, proposedLocally := r.mu.proposals[idKey]
52995299

53005300
// TODO(tschottdorf): consider the Trace situation here.
53015301
if proposedLocally {
53025302
// We initiated this command, so use the caller-supplied context.
53035303
ctx = proposal.ctx
53045304
proposal.ctx = nil // avoid confusion
5305-
delete(r.mu.localProposals, idKey)
5305+
delete(r.mu.proposals, idKey)
53065306
}
53075307

53085308
leaseIndex, proposalRetry, forcedErr := r.checkForcedErrLocked(ctx, idKey, raftCmd, proposal, proposedLocally)

pkg/storage/replica_sideload.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ func (r *Replica) maybeSideloadEntriesRaftMuLocked(
7171
maybeRaftCommand := func(cmdID storagebase.CmdIDKey) (storagepb.RaftCommand, bool) {
7272
r.mu.Lock()
7373
defer r.mu.Unlock()
74-
cmd, ok := r.mu.localProposals[cmdID]
74+
cmd, ok := r.mu.proposals[cmdID]
7575
if ok {
7676
return *cmd.command, true
7777
}

pkg/storage/replica_test.go

+5-5
Original file line numberDiff line numberDiff line change
@@ -7698,7 +7698,7 @@ func TestReplicaTryAbandon(t *testing.T) {
76987698
func() {
76997699
tc.repl.mu.Lock()
77007700
defer tc.repl.mu.Unlock()
7701-
if len(tc.repl.mu.localProposals) == 0 {
7701+
if len(tc.repl.mu.proposals) == 0 {
77027702
t.Fatal("expected non-empty proposals map")
77037703
}
77047704
}()
@@ -8254,7 +8254,7 @@ func TestReplicaBurstPendingCommandsAndRepropose(t *testing.T) {
82548254
}
82558255

82568256
tc.repl.mu.Lock()
8257-
for _, p := range tc.repl.mu.localProposals {
8257+
for _, p := range tc.repl.mu.proposals {
82588258
if v := p.ctx.Value(magicKey{}); v != nil {
82598259
origIndexes = append(origIndexes, int(p.command.MaxLeaseIndex))
82608260
}
@@ -8286,13 +8286,13 @@ func TestReplicaBurstPendingCommandsAndRepropose(t *testing.T) {
82868286

82878287
tc.repl.mu.Lock()
82888288
defer tc.repl.mu.Unlock()
8289-
nonePending := len(tc.repl.mu.localProposals) == 0
8289+
nonePending := len(tc.repl.mu.proposals) == 0
82908290
c := int(tc.repl.mu.lastAssignedLeaseIndex) - int(tc.repl.mu.state.LeaseAppliedIndex)
82918291
if nonePending && c > 0 {
82928292
t.Errorf("no pending cmds, but have required index offset %d", c)
82938293
}
82948294
if !nonePending {
8295-
t.Fatalf("still pending commands: %+v", tc.repl.mu.localProposals)
8295+
t.Fatalf("still pending commands: %+v", tc.repl.mu.proposals)
82968296
}
82978297
}
82988298

@@ -8450,7 +8450,7 @@ func TestReplicaRefreshPendingCommandsTicks(t *testing.T) {
84508450
}
84518451
// Build the map of expected reproposals at this stage.
84528452
m := map[storagebase.CmdIDKey]int{}
8453-
for id, p := range r.mu.localProposals {
8453+
for id, p := range r.mu.proposals {
84548454
m[id] = p.proposedAtTicks
84558455
}
84568456
r.mu.Unlock()

0 commit comments

Comments
 (0)