@@ -158,7 +158,10 @@ func CollectStoresReplicaInfo(
158
158
return loqrecoverypb.ClusterReplicaInfo {}, CollectionStats {}, errors .New ("can't collect info from stored that belong to different clusters" )
159
159
}
160
160
nodes [ident .NodeID ] = struct {}{}
161
- if err := visitStoreReplicas (ctx , reader , ident .StoreID , ident .NodeID , version ,
161
+ // TODO(sep-raft-log): use different readers when the raft and state machine
162
+ // engines are separate. Since the engines are immutable in this path, there
163
+ // is no question whether to and in which order to grab engine snapshots.
164
+ if err := visitStoreReplicas (ctx , reader , reader , ident .StoreID , ident .NodeID ,
162
165
func (info loqrecoverypb.ReplicaInfo ) error {
163
166
replicas = append (replicas , info )
164
167
return nil
@@ -178,19 +181,21 @@ func CollectStoresReplicaInfo(
178
181
179
182
func visitStoreReplicas (
180
183
ctx context.Context ,
181
- reader storage.Reader ,
184
+ state , raft storage.Reader ,
182
185
storeID roachpb.StoreID ,
183
186
nodeID roachpb.NodeID ,
184
- targetVersion clusterversion.ClusterVersion ,
185
187
send func (info loqrecoverypb.ReplicaInfo ) error ,
186
188
) error {
187
- if err := kvstorage .IterateRangeDescriptorsFromDisk (ctx , reader , func (desc roachpb.RangeDescriptor ) error {
189
+ if err := kvstorage .IterateRangeDescriptorsFromDisk (ctx , state , func (desc roachpb.RangeDescriptor ) error {
188
190
rsl := stateloader .Make (desc .RangeID )
189
- rstate , err := rsl .Load (ctx , reader , & desc )
191
+ rstate , err := rsl .Load (ctx , state , & desc )
190
192
if err != nil {
191
193
return err
192
194
}
193
- hstate , err := rsl .LoadHardState (ctx , reader )
195
+ // TODO(pav-kv): the LoQ recovery flow uses only the applied index, and the
196
+ // HardState.Commit loaded here is unused. Consider removing. Make sure this
197
+ // doesn't break compatibility for ReplicaInfo unmarshalling.
198
+ hstate , err := rsl .LoadHardState (ctx , raft )
194
199
if err != nil {
195
200
return err
196
201
}
@@ -199,8 +204,12 @@ func visitStoreReplicas(
199
204
// at potentially uncommitted entries as we have no way to determine their
200
205
// outcome, and they will become committed as soon as the replica is
201
206
// designated as a survivor.
207
+ // TODO(sep-raft-log): decide which LogID to read from. If the raft and
208
+ // state machine readers are slightly out of sync, the LogIDs may mismatch.
209
+ // For the heuristics here, it would probably make sense to read from all
210
+ // LogIDs with unapplied entries.
202
211
rangeUpdates , err := GetDescriptorChangesFromRaftLog (
203
- ctx , desc .RangeID , rstate .RaftAppliedIndex + 1 , math .MaxInt64 , reader )
212
+ ctx , desc .RangeID , rstate .RaftAppliedIndex + 1 , math .MaxInt64 , raft )
204
213
if err != nil {
205
214
return err
206
215
}
0 commit comments