@@ -22,9 +22,6 @@ import (
22
22
"strings"
23
23
"time"
24
24
25
- "github.com/pkg/errors"
26
- "go.etcd.io/etcd/raft/raftpb"
27
-
28
25
"github.com/cockroachdb/cockroach/pkg/base"
29
26
"github.com/cockroachdb/cockroach/pkg/internal/client"
30
27
"github.com/cockroachdb/cockroach/pkg/keys"
@@ -40,6 +37,9 @@ import (
40
37
"github.com/cockroachdb/cockroach/pkg/util/log"
41
38
"github.com/cockroachdb/cockroach/pkg/util/protoutil"
42
39
"github.com/cockroachdb/cockroach/pkg/util/retry"
40
+ "github.com/pkg/errors"
41
+ "go.etcd.io/etcd/raft"
42
+ "go.etcd.io/etcd/raft/raftpb"
43
43
)
44
44
45
45
// evaluateCommand delegates to the eval method for the given
@@ -197,6 +197,23 @@ func maybeDescriptorChangedError(desc *roachpb.RangeDescriptor, err error) (stri
197
197
return "" , false
198
198
}
199
199
200
+ func splitSnapshotWarningStr (rangeID roachpb.RangeID , status * raft.Status ) string {
201
+ var s string
202
+ if status != nil && status .RaftState == raft .StateLeader {
203
+ for replicaID , pr := range status .Progress {
204
+ if replicaID == status .Lead {
205
+ // TODO(tschottdorf): remove this line once we have picked up
206
+ // https://github.com/etcd-io/etcd/pull/10279
207
+ continue
208
+ }
209
+ if pr .State != raft .ProgressStateReplicate {
210
+ s += fmt .Sprintf ("; may cause Raft snapshot to r%d/%d: %v" , rangeID , replicaID , & pr )
211
+ }
212
+ }
213
+ }
214
+ return s
215
+ }
216
+
200
217
// adminSplitWithDescriptor divides the range into into two ranges, using
201
218
// either args.SplitKey (if provided) or an internally computed key that aims
202
219
// to roughly equipartition the range by size. The split is done inside of a
@@ -295,8 +312,10 @@ func (r *Replica) adminSplitWithDescriptor(
295
312
}
296
313
leftDesc .EndKey = splitKey
297
314
298
- log .Infof (ctx , "initiating a split of this range at key %s [r%d]" ,
299
- splitKey , rightDesc .RangeID )
315
+ extra := splitSnapshotWarningStr (r .RangeID , r .RaftStatus ())
316
+
317
+ log .Infof (ctx , "initiating a split of this range at key %s [r%d]%s" ,
318
+ splitKey , rightDesc .RangeID , extra )
300
319
301
320
if err := r .store .DB ().Txn (ctx , func (ctx context.Context , txn * client.Txn ) error {
302
321
log .Event (ctx , "split closure begins" )
0 commit comments