Skip to content

Commit

Permalink
cli: persist new replica ID in unsafe-remove-dead-replicas
Browse files Browse the repository at this point in the history
The recently introduced local `RaftReplicaIDKey` was not updated when
`unsafe-remove-dead-replicas` changed the replica's ID. This could lead
to assertion failures.

Release note: None
  • Loading branch information
erikgrinaker committed Apr 25, 2022
1 parent 8fe42c1 commit cdc4623
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions pkg/cli/debug.go
Original file line number Diff line number Diff line change
Expand Up @@ -1371,6 +1371,15 @@ func removeDeadReplicas(
batch.Close()
return nil, err
}
// Write the new replica ID to RaftReplicaIDKey.
replicas := desc.Replicas().Descriptors()
if len(replicas) != 1 {
return nil, errors.Errorf("expected 1 replica, got %v", replicas)
}
if err := sl.SetRaftReplicaID(ctx, batch, replicas[0].ReplicaID); err != nil {
return nil, errors.Wrapf(err, "failed to write new replica ID for range %d", desc.RangeID)
}
// Update MVCC stats.
if err := sl.SetMVCCStats(ctx, batch, &ms); err != nil {
return nil, errors.Wrap(err, "updating MVCCStats")
}
Expand Down

0 comments on commit cdc4623

Please sign in to comment.