Skip to content

Commit

Permalink
Merge #43011
Browse files Browse the repository at this point in the history
43011: storage: removed redundant activeVersion argument r=irfansharif a=irfansharif

Clean up all comments/plumbed instances of the activeVersion passed
through.

Release note: None

Co-authored-by: irfan sharif <irfanmahmoudsharif@gmail.com>
  • Loading branch information
craig[bot] and irfansharif committed Dec 11, 2019
2 parents 6f5de7b + c658b70 commit c7fe530
Show file tree
Hide file tree
Showing 5 changed files with 4 additions and 23 deletions.
3 changes: 1 addition & 2 deletions pkg/storage/batcheval/cmd_end_transaction.go
Original file line number Diff line number Diff line change
Expand Up @@ -1008,10 +1008,9 @@ func splitTriggerHelper(
// writeInitialReplicaState which essentially writes a ReplicaState
// only.

v := cluster.Version.ActiveVersion(ctx, rec.ClusterSettings()).Version
*h.AbsPostSplitRight(), err = stateloader.WriteInitialReplicaState(
ctx, batch, *h.AbsPostSplitRight(), split.RightDesc, rightLease,
*gcThreshold, v, truncStateType,
*gcThreshold, truncStateType,
)
if err != nil {
return enginepb.MVCCStats{}, result.Result{}, errors.Wrap(err, "unable to write initial Replica state")
Expand Down
1 change: 0 additions & 1 deletion pkg/storage/replica_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,6 @@ func (tc *testContext) StartWithStoreConfigAndVersion(
*testDesc,
roachpb.BootstrapLease(),
hlc.Timestamp{},
bootstrapVersion,
stateloader.TruncatedStateUnreplicated,
); err != nil {
t.Fatal(err)
Expand Down
16 changes: 1 addition & 15 deletions pkg/storage/stateloader/initial.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,26 +38,16 @@ const (
// entries already having applied. The supplied MVCCStats are used for the Stats
// field after adjusting for persisting the state itself, and the updated stats
// are returned.
//
// Args:
// activeVersion: The cluster's version.
func WriteInitialReplicaState(
ctx context.Context,
eng engine.ReadWriter,
ms enginepb.MVCCStats,
desc roachpb.RangeDescriptor,
lease roachpb.Lease,
gcThreshold hlc.Timestamp,
activeVersion roachpb.Version,
truncStateType TruncatedStateType,
) (enginepb.MVCCStats, error) {
rsl := Make(desc.RangeID)
// NB: be careful using activeVersion here. One caller of this code is the
// split trigger, and the version with which the split trigger is called can
// vary across followers. Thus, actions which require coordination cannot
// use the version as a trigger (this is why this method takes a
// truncStateType argument).

var s storagepb.ReplicaState
s.TruncatedState = &roachpb.RaftTruncatedState{
Term: raftInitialLogTerm,
Expand Down Expand Up @@ -96,21 +86,17 @@ func WriteInitialReplicaState(
// SynthesizeRaftState. It is typically called during bootstrap. The supplied
// MVCCStats are used for the Stats field after adjusting for persisting the
// state itself, and the updated stats are returned.
//
// Args:
// bootstrapVersion: The version at which the cluster is bootstrapped.
func WriteInitialState(
ctx context.Context,
eng engine.ReadWriter,
ms enginepb.MVCCStats,
desc roachpb.RangeDescriptor,
lease roachpb.Lease,
gcThreshold hlc.Timestamp,
bootstrapVersion roachpb.Version,
truncStateType TruncatedStateType,
) (enginepb.MVCCStats, error) {
newMS, err := WriteInitialReplicaState(
ctx, eng, ms, desc, lease, gcThreshold, bootstrapVersion, truncStateType)
ctx, eng, ms, desc, lease, gcThreshold, truncStateType)
if err != nil {
return enginepb.MVCCStats{}, err
}
Expand Down
1 change: 0 additions & 1 deletion pkg/storage/store_bootstrap.go
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,6 @@ func WriteInitialClusterData(
*desc,
lease,
hlc.Timestamp{}, /* gcThreshold */
bootstrapVersion,
truncStateType,
)
if err != nil {
Expand Down
6 changes: 2 additions & 4 deletions pkg/storage/store_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1353,10 +1353,9 @@ func splitTestRange(store *Store, key, splitKey roachpb.RKey, t *testing.T) *Rep
rangeID, splitKey, repl.Desc().EndKey, repl.Desc().Replicas())
// Minimal amount of work to keep this deprecated machinery working: Write
// some required Raft keys.
cv := cluster.Version.ActiveVersion(ctx, store.ClusterSettings()).Version
_, err = stateloader.WriteInitialState(
ctx, store.engine, enginepb.MVCCStats{}, *rhsDesc, roachpb.Lease{},
hlc.Timestamp{}, cv, stateloader.TruncatedStateUnreplicated,
hlc.Timestamp{}, stateloader.TruncatedStateUnreplicated,
)
require.NoError(t, err)
newRng, err := NewReplica(rhsDesc, store, 0)
Expand Down Expand Up @@ -2888,10 +2887,9 @@ func TestStoreRemovePlaceholderOnRaftIgnored(t *testing.T) {
}

uninitDesc := roachpb.RangeDescriptor{RangeID: repl1.Desc().RangeID}
cv := cluster.Version.ActiveVersion(ctx, s.ClusterSettings()).Version
if _, err := stateloader.WriteInitialState(
ctx, s.Engine(), enginepb.MVCCStats{}, uninitDesc, roachpb.Lease{},
hlc.Timestamp{}, cv, stateloader.TruncatedStateUnreplicated,
hlc.Timestamp{}, stateloader.TruncatedStateUnreplicated,
); err != nil {
t.Fatal(err)
}
Expand Down

0 comments on commit c7fe530

Please sign in to comment.