Skip to content

Commit

Permalink
storage: add replica pointer tag
Browse files Browse the repository at this point in the history
Debugging aid for cockroachdb#11591.
  • Loading branch information
petermattis committed Nov 29, 2016
1 parent 7b73805 commit a0d3054
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 0 deletions.
2 changes: 2 additions & 0 deletions pkg/storage/replica.go
Original file line number Diff line number Diff line change
Expand Up @@ -572,6 +572,8 @@ func newReplica(rangeID roachpb.RangeID, store *Store) *Replica {
r.rangeStr.store(0, &roachpb.RangeDescriptor{RangeID: rangeID})
// Add replica log tag - the value is rangeStr.String().
r.AmbientContext.AddLogTag("r", &r.rangeStr)
// Add replica pointer value.
r.AmbientContext.AddLogTagStr("@", fmt.Sprintf("%x", r))

raftMuLogger := syncutil.ThresholdLogger(
r.AnnotateCtx(context.Background()),
Expand Down
2 changes: 2 additions & 0 deletions pkg/storage/store.go
Original file line number Diff line number Diff line change
Expand Up @@ -1988,6 +1988,8 @@ func (s *Store) RemoveReplica(
func (s *Store) removeReplicaImpl(
ctx context.Context, rep *Replica, origDesc roachpb.RangeDescriptor, destroyData bool,
) error {
log.Infof(ctx, "removing replica")

desc := rep.Desc()
if repDesc, ok := desc.GetReplicaDescriptor(s.StoreID()); ok && repDesc.ReplicaID >= origDesc.NextReplicaID {
return errors.Errorf("cannot remove replica %s; replica ID has changed (%s >= %s)",
Expand Down

0 comments on commit a0d3054

Please sign in to comment.