@@ -33,6 +33,7 @@ import (
3333 "github.com/cockroachdb/cockroach/pkg/kv/kvserver/kvserverpb"
3434 "github.com/cockroachdb/cockroach/pkg/kv/kvserver/liveness"
3535 "github.com/cockroachdb/cockroach/pkg/kv/kvserver/liveness/livenesspb"
36+ "github.com/cockroachdb/cockroach/pkg/kv/kvserver/logstore"
3637 "github.com/cockroachdb/cockroach/pkg/kv/kvserver/rditer"
3738 "github.com/cockroachdb/cockroach/pkg/kv/kvserver/stateloader"
3839 raft "github.com/cockroachdb/cockroach/pkg/raft"
@@ -5326,13 +5327,13 @@ func TestProcessSplitAfterRightHandSideHasBeenRemoved(t *testing.T) {
53265327 t * testing.T , store * kvserver.Store , rangeID roachpb.RangeID ,
53275328 ) raftpb.HardState {
53285329 t .Helper ()
5329- hs , err := stateloader . Make (rangeID ).LoadHardState (ctx , store .TODOEngine ())
5330+ hs , err := logstore . NewStateLoader (rangeID ).LoadHardState (ctx , store .LogEngine ())
53305331 require .NoError (t , err )
53315332 return hs
53325333 }
53335334 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) .
53365337 var setupOnce sync.Once
53375338 f := kvserverbase .ReplicaProposalFilter (func (args kvserverbase.ProposalFilterArgs ) * kvpb.Error {
53385339 req , ok := args .Req .GetArg (kvpb .EndTxn )
@@ -5363,9 +5364,10 @@ func TestProcessSplitAfterRightHandSideHasBeenRemoved(t *testing.T) {
53635364 proposalFilter .Store (f )
53645365 }
53655366
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.
53695371 //
53705372 // Different outcomes will occur depending on whether and how the RHS is
53715373 // partitioned and whether the server is killed. In all cases we want the
@@ -5400,6 +5402,11 @@ func TestProcessSplitAfterRightHandSideHasBeenRemoved(t *testing.T) {
54005402 // Newly-started stores (including the "rogue" one) should not GC
54015403 // their replicas. We'll turn this back on when needed.
54025404 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 ,
54035410 TestingProposalFilter : testingProposalFilter ,
54045411 },
54055412 },
@@ -5486,9 +5493,9 @@ func TestProcessSplitAfterRightHandSideHasBeenRemoved(t *testing.T) {
54865493 target := tc .Target (0 )
54875494 log .KvExec .Infof (ctx , "removing voter: %v" , target )
54885495 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.
54925499 _ , err = tc .Servers [0 ].DB ().AdminChangeReplicas (
54935500 ctx , keyB , tc .LookupRangeOrFatal (t , keyB ),
54945501 kvpb .MakeReplicationChanges (roachpb .ADD_VOTER , target ),
@@ -5701,8 +5708,8 @@ func TestProcessSplitAfterRightHandSideHasBeenRemoved(t *testing.T) {
57015708 target := tc .Target (0 )
57025709 log .KvExec .Infof (ctx , "removing voter: %v" , target )
57035710 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
57065713 // has been removed at the old replica ID.
57075714 //
57085715 // Not using tc.AddVoters because we expect an error, but that error
@@ -5722,7 +5729,7 @@ func TestProcessSplitAfterRightHandSideHasBeenRemoved(t *testing.T) {
57225729 log .KvExec .Infof (ctx , "added %d to RHS partition: %s" , rhsInfo .Desc .NextReplicaID , rhsPartition )
57235730
57245731 // 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
57265733 // the store. Previously there were races which could happen if we
57275734 // stopped the store immediately. Sleeps worked but this feels somehow
57285735 // more principled.
0 commit comments