@@ -79,7 +79,7 @@ func loadInitializedReplicaForTesting(
79
79
func newInitializedReplica (
80
80
store * Store , loaded kvstorage.LoadedReplicaState , waitForPrevLeaseToExpire bool ,
81
81
) (* Replica , error ) {
82
- r := newUninitializedReplicaWithoutRaftGroup (store , loaded .ReplState . Desc . RangeID , loaded . ReplicaID )
82
+ r := newUninitializedReplicaWithoutRaftGroup (store , loaded .FullReplicaID () )
83
83
r .raftMu .Lock ()
84
84
defer r .raftMu .Unlock ()
85
85
r .mu .Lock ()
@@ -99,10 +99,8 @@ func newInitializedReplica(
99
99
//
100
100
// TODO(#94912): we actually have another initialization path which should be
101
101
// 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 )
106
104
r .raftMu .Lock ()
107
105
defer r .raftMu .Unlock ()
108
106
r .mu .Lock ()
@@ -118,17 +116,15 @@ func newUninitializedReplica(
118
116
// newUninitializedReplica() instead. This only exists for
119
117
// newInitializedReplica() to avoid creating the Raft group twice (once when
120
118
// 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 )
125
121
r := & Replica {
126
122
AmbientContext : store .cfg .AmbientCtx ,
127
- RangeID : rangeID ,
128
- replicaID : replicaID ,
123
+ RangeID : id . RangeID ,
124
+ replicaID : id . ReplicaID ,
129
125
creationTime : timeutil .Now (),
130
126
store : store ,
131
- abortSpan : abortspan .New (rangeID ),
127
+ abortSpan : abortspan .New (id . RangeID ),
132
128
concMgr : concurrency .NewManager (concurrency.Config {
133
129
NodeDesc : store .nodeDesc ,
134
130
RangeDesc : uninitState .Desc ,
@@ -145,7 +141,7 @@ func newUninitializedReplicaWithoutRaftGroup(
145
141
}),
146
142
allocatorToken : & plan.AllocatorToken {},
147
143
}
148
- r .sideTransportClosedTimestamp .init (store .cfg .ClosedTimestampReceiver , rangeID )
144
+ r .sideTransportClosedTimestamp .init (store .cfg .ClosedTimestampReceiver , id . RangeID )
149
145
r .cachedClosedTimestampPolicy .Store (new (ctpb.RangeClosedTimestampPolicy ))
150
146
151
147
r .mu .pendingLeaseRequest = makePendingLeaseRequest (r )
@@ -165,9 +161,9 @@ func newUninitializedReplicaWithoutRaftGroup(
165
161
// Expose proposal data for external test packages.
166
162
return store .cfg .TestingKnobs .TestingProposalSubmitFilter (kvserverbase.ProposalFilterArgs {
167
163
Ctx : p .Context (),
168
- RangeID : rangeID ,
164
+ RangeID : id . RangeID ,
169
165
StoreID : store .StoreID (),
170
- ReplicaID : replicaID ,
166
+ ReplicaID : id . ReplicaID ,
171
167
Cmd : p .command ,
172
168
QuotaAlloc : p .quotaAlloc ,
173
169
CmdID : p .idKey ,
@@ -196,7 +192,7 @@ func newUninitializedReplicaWithoutRaftGroup(
196
192
// NB: state will be loaded when the replica gets initialized.
197
193
r .shMu .state = uninitState
198
194
199
- r .rangeStr .store (replicaID , uninitState .Desc )
195
+ r .rangeStr .store (id . ReplicaID , uninitState .Desc )
200
196
// Add replica log tag - the value is rangeStr.String().
201
197
r .AmbientContext .AddLogTag ("r" , & r .rangeStr )
202
198
r .raftCtx = logtags .AddTag (r .AnnotateCtx (context .Background ()), "raft" , nil /* value */ )
@@ -205,14 +201,14 @@ func newUninitializedReplicaWithoutRaftGroup(
205
201
// r.AmbientContext.AddLogTag("@", fmt.Sprintf("%x", unsafe.Pointer(r)))
206
202
207
203
r .raftMu .rangefeedCTLagObserver = newRangeFeedCTLagObserver ()
208
- r .raftMu .stateLoader = stateloader .Make (rangeID )
204
+ r .raftMu .stateLoader = stateloader .Make (id . RangeID )
209
205
210
206
// Initialize all the components of the log storage. The state of the log
211
207
// storage, such as RaftTruncatedState and the last entry ID, will be loaded
212
208
// when the replica is initialized.
213
209
sideloaded := logstore .NewDiskSideloadStorage (
214
210
store .cfg .Settings ,
215
- rangeID ,
211
+ id . RangeID ,
216
212
// NB: sideloaded log entries are persisted in the state engine so that they
217
213
// can be ingested to the state machine locally, when being applied.
218
214
store .StateEngine ().GetAuxiliaryDir (),
@@ -229,13 +225,13 @@ func newUninitializedReplicaWithoutRaftGroup(
229
225
r .logStorage .mu .RWMutex = (* syncutil .RWMutex )(& r .mu .ReplicaMutex )
230
226
r .logStorage .raftMu .Mutex = & r .raftMu .Mutex
231
227
r .logStorage .ls = & logstore.LogStore {
232
- RangeID : rangeID ,
228
+ RangeID : id . RangeID ,
233
229
Engine : store .LogEngine (),
234
230
Sideload : sideloaded ,
235
231
StateLoader : r .raftMu .stateLoader .StateLoader ,
236
232
// NOTE: use the same SyncWaiter loop for all raft log writes performed by a
237
233
// 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 )],
239
235
Settings : store .cfg .Settings ,
240
236
DisableSyncLogWriteToss : buildutil .CrdbTestBuild &&
241
237
store .TestingKnobs ().DisableSyncLogWriteToss ,
0 commit comments