Skip to content

Commit 412e2bd

Browse files
committed
kvserver: drive-by fixups
Epic: none Release note: none
1 parent 892744f commit 412e2bd

File tree

1 file changed

+14
-12
lines changed

1 file changed

+14
-12
lines changed

pkg/kv/kvserver/client_raft_test.go

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -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"
@@ -5320,13 +5321,13 @@ func TestProcessSplitAfterRightHandSideHasBeenRemoved(t *testing.T) {
53205321
t *testing.T, store *kvserver.Store, rangeID roachpb.RangeID,
53215322
) raftpb.HardState {
53225323
t.Helper()
5323-
hs, err := stateloader.Make(rangeID).LoadHardState(ctx, store.TODOEngine())
5324+
hs, err := logstore.NewStateLoader(rangeID).LoadHardState(ctx, store.LogEngine())
53245325
require.NoError(t, err)
53255326
return hs
53265327
}
53275328
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).
53305331
var setupOnce sync.Once
53315332
f := kvserverbase.ReplicaProposalFilter(func(args kvserverbase.ProposalFilterArgs) *kvpb.Error {
53325333
req, ok := args.Req.GetArg(kvpb.EndTxn)
@@ -5357,9 +5358,10 @@ func TestProcessSplitAfterRightHandSideHasBeenRemoved(t *testing.T) {
53575358
proposalFilter.Store(f)
53585359
}
53595360

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.
53635365
//
53645366
// Different outcomes will occur depending on whether and how the RHS is
53655367
// partitioned and whether the server is killed. In all cases we want the
@@ -5480,9 +5482,9 @@ func TestProcessSplitAfterRightHandSideHasBeenRemoved(t *testing.T) {
54805482
target := tc.Target(0)
54815483
log.KvExec.Infof(ctx, "removing voter: %v", target)
54825484
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.
54865488
_, err = tc.Servers[0].DB().AdminChangeReplicas(
54875489
ctx, keyB, tc.LookupRangeOrFatal(t, keyB),
54885490
kvpb.MakeReplicationChanges(roachpb.ADD_VOTER, target),
@@ -5695,8 +5697,8 @@ func TestProcessSplitAfterRightHandSideHasBeenRemoved(t *testing.T) {
56955697
target := tc.Target(0)
56965698
log.KvExec.Infof(ctx, "removing voter: %v", target)
56975699
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
57005702
// has been removed at the old replica ID.
57015703
//
57025704
// Not using tc.AddVoters because we expect an error, but that error
@@ -5716,7 +5718,7 @@ func TestProcessSplitAfterRightHandSideHasBeenRemoved(t *testing.T) {
57165718
log.KvExec.Infof(ctx, "added %d to RHS partition: %s", rhsInfo.Desc.NextReplicaID, rhsPartition)
57175719

57185720
// 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
57205722
// the store. Previously there were races which could happen if we
57215723
// stopped the store immediately. Sleeps worked but this feels somehow
57225724
// more principled.

0 commit comments

Comments
 (0)