From 72a7747b05e356cf9b458fa6aade8fb5a6c7bce9 Mon Sep 17 00:00:00 2001 From: Tobias Schottdorf Date: Mon, 26 Nov 2018 12:39:31 +0100 Subject: [PATCH] storage: indicate when a split causes a Raft snapshot Touches #31409. Release note: None --- pkg/storage/replica_command.go | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/pkg/storage/replica_command.go b/pkg/storage/replica_command.go index 07eb3cade222..38a7894d9285 100644 --- a/pkg/storage/replica_command.go +++ b/pkg/storage/replica_command.go @@ -22,9 +22,6 @@ import ( "strings" "time" - "github.com/pkg/errors" - "go.etcd.io/etcd/raft/raftpb" - "github.com/cockroachdb/cockroach/pkg/base" "github.com/cockroachdb/cockroach/pkg/internal/client" "github.com/cockroachdb/cockroach/pkg/keys" @@ -42,6 +39,9 @@ import ( "github.com/cockroachdb/cockroach/pkg/util/log" "github.com/cockroachdb/cockroach/pkg/util/protoutil" "github.com/cockroachdb/cockroach/pkg/util/retry" + "github.com/pkg/errors" + "go.etcd.io/etcd/raft" + "go.etcd.io/etcd/raft/raftpb" ) // evaluateCommand delegates to the eval method for the given @@ -303,8 +303,22 @@ func (r *Replica) adminSplitWithDescriptor( } leftDesc.EndKey = splitKey - log.Infof(ctx, "initiating a split of this range at key %s [r%d]", - splitKey, rightDesc.RangeID) + var extra string + if status := r.RaftStatus(); status != nil && status.RaftState == raft.StateLeader { + for replicaID, pr := range status.Progress { + if replicaID == status.Lead { + // TODO(tschottdorf): remove this line once we have picked up + // https://github.com/etcd-io/etcd/pull/10279 + continue + } + if pr.State == raft.ProgressStateReplicate { + extra += fmt.Sprintf("; may cause Raft snapshot to r%d/%d: %v", r.RangeID, replicaID, &pr) + } + } + } + + log.Infof(ctx, "initiating a split of this range at key %s [r%d]%s", + splitKey, rightDesc.RangeID, extra) if err := r.store.DB().Txn(ctx, func(ctx context.Context, txn *client.Txn) error { log.Event(ctx, "split closure begins")