@@ -79,7 +79,7 @@ func loadInitializedReplicaForTesting(
7979func newInitializedReplica (
8080 store * Store , loaded kvstorage.LoadedReplicaState , waitForPrevLeaseToExpire bool ,
8181) (* Replica , error ) {
82- r := newUninitializedReplicaWithoutRaftGroup (store , loaded .ReplState . Desc . RangeID , loaded . ReplicaID )
82+ r := newUninitializedReplicaWithoutRaftGroup (store , loaded .FullReplicaID () )
8383 r .raftMu .Lock ()
8484 defer r .raftMu .Unlock ()
8585 r .mu .Lock ()
@@ -99,10 +99,8 @@ func newInitializedReplica(
9999//
100100// TODO(#94912): we actually have another initialization path which should be
101101// refactored: Replica.initFromSnapshotLockedRaftMuLocked().
102- func newUninitializedReplica (
103- store * Store , rangeID roachpb.RangeID , replicaID roachpb.ReplicaID ,
104- ) (* Replica , error ) {
105- r := newUninitializedReplicaWithoutRaftGroup (store , rangeID , replicaID )
102+ func newUninitializedReplica (store * Store , id roachpb.FullReplicaID ) (* Replica , error ) {
103+ r := newUninitializedReplicaWithoutRaftGroup (store , id )
106104 r .raftMu .Lock ()
107105 defer r .raftMu .Unlock ()
108106 r .mu .Lock ()
@@ -118,17 +116,15 @@ func newUninitializedReplica(
118116// newUninitializedReplica() instead. This only exists for
119117// newInitializedReplica() to avoid creating the Raft group twice (once when
120118// creating the uninitialized replica, and once when initializing it).
121- func newUninitializedReplicaWithoutRaftGroup (
122- store * Store , rangeID roachpb.RangeID , replicaID roachpb.ReplicaID ,
123- ) * Replica {
124- uninitState := stateloader .UninitializedReplicaState (rangeID )
119+ func newUninitializedReplicaWithoutRaftGroup (store * Store , id roachpb.FullReplicaID ) * Replica {
120+ uninitState := stateloader .UninitializedReplicaState (id .RangeID )
125121 r := & Replica {
126122 AmbientContext : store .cfg .AmbientCtx ,
127- RangeID : rangeID ,
128- replicaID : replicaID ,
123+ RangeID : id . RangeID ,
124+ replicaID : id . ReplicaID ,
129125 creationTime : timeutil .Now (),
130126 store : store ,
131- abortSpan : abortspan .New (rangeID ),
127+ abortSpan : abortspan .New (id . RangeID ),
132128 concMgr : concurrency .NewManager (concurrency.Config {
133129 NodeDesc : store .nodeDesc ,
134130 RangeDesc : uninitState .Desc ,
@@ -145,7 +141,7 @@ func newUninitializedReplicaWithoutRaftGroup(
145141 }),
146142 allocatorToken : & plan.AllocatorToken {},
147143 }
148- r .sideTransportClosedTimestamp .init (store .cfg .ClosedTimestampReceiver , rangeID )
144+ r .sideTransportClosedTimestamp .init (store .cfg .ClosedTimestampReceiver , id . RangeID )
149145 r .cachedClosedTimestampPolicy .Store (new (ctpb.RangeClosedTimestampPolicy ))
150146
151147 r .mu .pendingLeaseRequest = makePendingLeaseRequest (r )
@@ -165,9 +161,9 @@ func newUninitializedReplicaWithoutRaftGroup(
165161 // Expose proposal data for external test packages.
166162 return store .cfg .TestingKnobs .TestingProposalSubmitFilter (kvserverbase.ProposalFilterArgs {
167163 Ctx : p .Context (),
168- RangeID : rangeID ,
164+ RangeID : id . RangeID ,
169165 StoreID : store .StoreID (),
170- ReplicaID : replicaID ,
166+ ReplicaID : id . ReplicaID ,
171167 Cmd : p .command ,
172168 QuotaAlloc : p .quotaAlloc ,
173169 CmdID : p .idKey ,
@@ -196,7 +192,7 @@ func newUninitializedReplicaWithoutRaftGroup(
196192 // NB: state will be loaded when the replica gets initialized.
197193 r .shMu .state = uninitState
198194
199- r .rangeStr .store (replicaID , uninitState .Desc )
195+ r .rangeStr .store (id . ReplicaID , uninitState .Desc )
200196 // Add replica log tag - the value is rangeStr.String().
201197 r .AmbientContext .AddLogTag ("r" , & r .rangeStr )
202198 r .raftCtx = logtags .AddTag (r .AnnotateCtx (context .Background ()), "raft" , nil /* value */ )
@@ -205,14 +201,14 @@ func newUninitializedReplicaWithoutRaftGroup(
205201 // r.AmbientContext.AddLogTag("@", fmt.Sprintf("%x", unsafe.Pointer(r)))
206202
207203 r .raftMu .rangefeedCTLagObserver = newRangeFeedCTLagObserver ()
208- r .raftMu .stateLoader = stateloader .Make (rangeID )
204+ r .raftMu .stateLoader = stateloader .Make (id . RangeID )
209205
210206 // Initialize all the components of the log storage. The state of the log
211207 // storage, such as RaftTruncatedState and the last entry ID, will be loaded
212208 // when the replica is initialized.
213209 sideloaded := logstore .NewDiskSideloadStorage (
214210 store .cfg .Settings ,
215- rangeID ,
211+ id . RangeID ,
216212 // NB: sideloaded log entries are persisted in the state engine so that they
217213 // can be ingested to the state machine locally, when being applied.
218214 store .StateEngine ().GetAuxiliaryDir (),
@@ -229,13 +225,13 @@ func newUninitializedReplicaWithoutRaftGroup(
229225 r .logStorage .mu .RWMutex = (* syncutil .RWMutex )(& r .mu .ReplicaMutex )
230226 r .logStorage .raftMu .Mutex = & r .raftMu .Mutex
231227 r .logStorage .ls = & logstore.LogStore {
232- RangeID : rangeID ,
228+ RangeID : id . RangeID ,
233229 Engine : store .LogEngine (),
234230 Sideload : sideloaded ,
235231 StateLoader : r .raftMu .stateLoader .StateLoader ,
236232 // NOTE: use the same SyncWaiter loop for all raft log writes performed by a
237233 // given range ID, to ensure that callbacks are processed in order.
238- SyncWaiter : store .syncWaiters [int (rangeID )% len (store .syncWaiters )],
234+ SyncWaiter : store .syncWaiters [int (id . RangeID )% len (store .syncWaiters )],
239235 Settings : store .cfg .Settings ,
240236 DisableSyncLogWriteToss : buildutil .CrdbTestBuild &&
241237 store .TestingKnobs ().DisableSyncLogWriteToss ,
0 commit comments