@@ -33,6 +33,7 @@ import (
33
33
"github.com/cockroachdb/cockroach/pkg/kv/kvserver/kvserverpb"
34
34
"github.com/cockroachdb/cockroach/pkg/kv/kvserver/liveness"
35
35
"github.com/cockroachdb/cockroach/pkg/kv/kvserver/liveness/livenesspb"
36
+ "github.com/cockroachdb/cockroach/pkg/kv/kvserver/logstore"
36
37
"github.com/cockroachdb/cockroach/pkg/kv/kvserver/rditer"
37
38
"github.com/cockroachdb/cockroach/pkg/kv/kvserver/stateloader"
38
39
raft "github.com/cockroachdb/cockroach/pkg/raft"
@@ -5326,13 +5327,13 @@ func TestProcessSplitAfterRightHandSideHasBeenRemoved(t *testing.T) {
5326
5327
t * testing.T , store * kvserver.Store , rangeID roachpb.RangeID ,
5327
5328
) raftpb.HardState {
5328
5329
t .Helper ()
5329
- hs , err := stateloader . Make (rangeID ).LoadHardState (ctx , store .TODOEngine ())
5330
+ hs , err := logstore . NewStateLoader (rangeID ).LoadHardState (ctx , store .LogEngine ())
5330
5331
require .NoError (t , err )
5331
5332
return hs
5332
5333
}
5333
5334
partitionReplicaOnSplit := func (t * testing.T , tc * testcluster.TestCluster , key roachpb.Key , basePartition * testClusterPartitionedRange , partRange * * testClusterPartitionedRange ) {
5334
- // Set up a hook to partition the RHS range at its initial range ID
5335
- // before proposing the split trigger.
5335
+ // Set up a hook to partition away the first store of the RHS range at the
5336
+ // first opportunity (when the split trigger is proposed) .
5336
5337
var setupOnce sync.Once
5337
5338
f := kvserverbase .ReplicaProposalFilter (func (args kvserverbase.ProposalFilterArgs ) * kvpb.Error {
5338
5339
req , ok := args .Req .GetArg (kvpb .EndTxn )
@@ -5363,9 +5364,10 @@ func TestProcessSplitAfterRightHandSideHasBeenRemoved(t *testing.T) {
5363
5364
proposalFilter .Store (f )
5364
5365
}
5365
5366
5366
- // The basic setup for all of these tests are that we have a LHS range on 3
5367
- // nodes and we've partitioned store 0 for the LHS range. The tests will now
5368
- // perform a split, remove the RHS, add it back and validate assumptions.
5367
+ // The basic setup for all of these tests are that we have an LHS range on 3
5368
+ // nodes (lease on the last one), and we've partitioned store 0 for the LHS
5369
+ // range. The tests will now perform a split, remove the RHS, add it back
5370
+ // and validate assumptions.
5369
5371
//
5370
5372
// Different outcomes will occur depending on whether and how the RHS is
5371
5373
// partitioned and whether the server is killed. In all cases we want the
@@ -5400,6 +5402,11 @@ func TestProcessSplitAfterRightHandSideHasBeenRemoved(t *testing.T) {
5400
5402
// Newly-started stores (including the "rogue" one) should not GC
5401
5403
// their replicas. We'll turn this back on when needed.
5402
5404
DisableReplicaGCQueue : true ,
5405
+ // Some subtests, e.g. (4), expect that n1 catches up on the raft
5406
+ // log after a partition, and runs the split trigger. Disable raft
5407
+ // log truncation to make sure that it doesn't miss the split
5408
+ // trigger by being caught up by a later snapshot. See #154313.
5409
+ DisableRaftLogQueue : true ,
5403
5410
TestingProposalFilter : testingProposalFilter ,
5404
5411
},
5405
5412
},
@@ -5486,9 +5493,9 @@ func TestProcessSplitAfterRightHandSideHasBeenRemoved(t *testing.T) {
5486
5493
target := tc .Target (0 )
5487
5494
log .KvExec .Infof (ctx , "removing voter: %v" , target )
5488
5495
tc .RemoveVotersOrFatal (t , keyB , target )
5489
- // Unsuccessful because the RHS will not accept the learner snapshot
5490
- // and will be rolled back. Nevertheless it will have learned that it
5491
- // has been removed at the old replica ID.
5496
+ // Unsuccessful because the RHS will not accept the learner snapshot and
5497
+ // will be rolled back. Nevertheless, it will have learned that it has
5498
+ // been removed at the old replica ID.
5492
5499
_ , err = tc .Servers [0 ].DB ().AdminChangeReplicas (
5493
5500
ctx , keyB , tc .LookupRangeOrFatal (t , keyB ),
5494
5501
kvpb .MakeReplicationChanges (roachpb .ADD_VOTER , target ),
@@ -5701,8 +5708,8 @@ func TestProcessSplitAfterRightHandSideHasBeenRemoved(t *testing.T) {
5701
5708
target := tc .Target (0 )
5702
5709
log .KvExec .Infof (ctx , "removing voter: %v" , target )
5703
5710
tc .RemoveVotersOrFatal (t , keyB , target )
5704
- // Unsuccessfuly because the RHS will not accept the learner snapshot
5705
- // and will be rolled back. Nevertheless it will have learned that it
5711
+ // Unsuccessful because the RHS will not accept the learner snapshot
5712
+ // and will be rolled back. Nevertheless, it will have learned that it
5706
5713
// has been removed at the old replica ID.
5707
5714
//
5708
5715
// Not using tc.AddVoters because we expect an error, but that error
@@ -5722,7 +5729,7 @@ func TestProcessSplitAfterRightHandSideHasBeenRemoved(t *testing.T) {
5722
5729
log .KvExec .Infof (ctx , "added %d to RHS partition: %s" , rhsInfo .Desc .NextReplicaID , rhsPartition )
5723
5730
5724
5731
// We do all of this incrementing to ensure that nobody will ever
5725
- // succeed in sending a message the new RHS replica after we restart
5732
+ // succeed in sending a message to the new RHS replica after we restart
5726
5733
// the store. Previously there were races which could happen if we
5727
5734
// stopped the store immediately. Sleeps worked but this feels somehow
5728
5735
// more principled.
0 commit comments