@@ -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"
@@ -5320,13 +5321,13 @@ func TestProcessSplitAfterRightHandSideHasBeenRemoved(t *testing.T) {
5320
5321
t * testing.T , store * kvserver.Store , rangeID roachpb.RangeID ,
5321
5322
) raftpb.HardState {
5322
5323
t .Helper ()
5323
- hs , err := stateloader . Make (rangeID ).LoadHardState (ctx , store .TODOEngine ())
5324
+ hs , err := logstore . NewStateLoader (rangeID ).LoadHardState (ctx , store .LogEngine ())
5324
5325
require .NoError (t , err )
5325
5326
return hs
5326
5327
}
5327
5328
partitionReplicaOnSplit := func (t * testing.T , tc * testcluster.TestCluster , key roachpb.Key , basePartition * testClusterPartitionedRange , partRange * * testClusterPartitionedRange ) {
5328
- // Set up a hook to partition the RHS range at its initial range ID
5329
- // before proposing the split trigger.
5329
+ // Set up a hook to partition away the first store of the RHS range at the
5330
+ // first opportunity (when the split trigger is proposed) .
5330
5331
var setupOnce sync.Once
5331
5332
f := kvserverbase .ReplicaProposalFilter (func (args kvserverbase.ProposalFilterArgs ) * kvpb.Error {
5332
5333
req , ok := args .Req .GetArg (kvpb .EndTxn )
@@ -5357,9 +5358,10 @@ func TestProcessSplitAfterRightHandSideHasBeenRemoved(t *testing.T) {
5357
5358
proposalFilter .Store (f )
5358
5359
}
5359
5360
5360
- // The basic setup for all of these tests are that we have a LHS range on 3
5361
- // nodes and we've partitioned store 0 for the LHS range. The tests will now
5362
- // perform a split, remove the RHS, add it back and validate assumptions.
5361
+ // The basic setup for all of these tests are that we have an LHS range on 3
5362
+ // nodes (lease on the last one), and we've partitioned store 0 for the LHS
5363
+ // range. The tests will now perform a split, remove the RHS, add it back
5364
+ // and validate assumptions.
5363
5365
//
5364
5366
// Different outcomes will occur depending on whether and how the RHS is
5365
5367
// partitioned and whether the server is killed. In all cases we want the
@@ -5480,9 +5482,9 @@ func TestProcessSplitAfterRightHandSideHasBeenRemoved(t *testing.T) {
5480
5482
target := tc .Target (0 )
5481
5483
log .KvExec .Infof (ctx , "removing voter: %v" , target )
5482
5484
tc .RemoveVotersOrFatal (t , keyB , target )
5483
- // Unsuccessful because the RHS will not accept the learner snapshot
5484
- // and will be rolled back. Nevertheless it will have learned that it
5485
- // has been removed at the old replica ID.
5485
+ // Unsuccessful because the RHS will not accept the learner snapshot and
5486
+ // will be rolled back. Nevertheless, it will have learned that it has
5487
+ // been removed at the old replica ID.
5486
5488
_ , err = tc .Servers [0 ].DB ().AdminChangeReplicas (
5487
5489
ctx , keyB , tc .LookupRangeOrFatal (t , keyB ),
5488
5490
kvpb .MakeReplicationChanges (roachpb .ADD_VOTER , target ),
@@ -5695,8 +5697,8 @@ func TestProcessSplitAfterRightHandSideHasBeenRemoved(t *testing.T) {
5695
5697
target := tc .Target (0 )
5696
5698
log .KvExec .Infof (ctx , "removing voter: %v" , target )
5697
5699
tc .RemoveVotersOrFatal (t , keyB , target )
5698
- // Unsuccessfuly because the RHS will not accept the learner snapshot
5699
- // and will be rolled back. Nevertheless it will have learned that it
5700
+ // Unsuccessful because the RHS will not accept the learner snapshot
5701
+ // and will be rolled back. Nevertheless, it will have learned that it
5700
5702
// has been removed at the old replica ID.
5701
5703
//
5702
5704
// Not using tc.AddVoters because we expect an error, but that error
@@ -5716,7 +5718,7 @@ func TestProcessSplitAfterRightHandSideHasBeenRemoved(t *testing.T) {
5716
5718
log .KvExec .Infof (ctx , "added %d to RHS partition: %s" , rhsInfo .Desc .NextReplicaID , rhsPartition )
5717
5719
5718
5720
// We do all of this incrementing to ensure that nobody will ever
5719
- // succeed in sending a message the new RHS replica after we restart
5721
+ // succeed in sending a message to the new RHS replica after we restart
5720
5722
// the store. Previously there were races which could happen if we
5721
5723
// stopped the store immediately. Sleeps worked but this feels somehow
5722
5724
// more principled.
0 commit comments