Skip to content

Commit 11a1e33

Browse files
committed
kvserver: rename for clarity
There are various stages of snapshots. Rename the types and method so that it's clear that we're preparing a snapshot for application (vs. for sending, etc).
1 parent a664f8e commit 11a1e33

File tree

2 files changed

+13
-12
lines changed

2 files changed

+13
-12
lines changed

pkg/kv/kvserver/replica_raftstorage.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -535,7 +535,7 @@ func (r *Replica) applySnapshotRaftMuLocked(
535535
}
536536

537537
st := r.ClusterSettings()
538-
prepInput := prepareSnapshotInput{
538+
prepInput := prepareSnapApplyInput{
539539
id: r.ID(),
540540

541541
st: st,
@@ -549,7 +549,7 @@ func (r *Replica) applySnapshotRaftMuLocked(
549549
subsumedDescs: subsumedDescs,
550550
}
551551

552-
prepResult, err := prepareSnapshot(ctx, prepInput)
552+
prepResult, err := prepareSnapApply(ctx, prepInput)
553553
if err != nil {
554554
return err
555555
}

pkg/kv/kvserver/snapshot_apply_prepare.go

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ import (
2121
"github.com/cockroachdb/errors"
2222
)
2323

24-
// prepareSnapshotInput contains the data needed to prepare the on-disk state for a snapshot.
25-
type prepareSnapshotInput struct {
24+
// prepareSnapApplyInput contains the data needed to prepare the on-disk state for a snapshot.
25+
type prepareSnapApplyInput struct {
2626
id storage.FullReplicaID
2727

2828
st *cluster.Settings
@@ -36,23 +36,24 @@ type prepareSnapshotInput struct {
3636
subsumedDescs []*roachpb.RangeDescriptor
3737
}
3838

39-
// preparedSnapshot contains the results of preparing the snapshot on disk.
40-
type preparedSnapshot struct {
39+
// preparedSnapApply contains the results of preparing the snapshot for ingestion.
40+
// TODO: remove
41+
type preparedSnapApply struct {
4142
clearedSpan roachpb.Span
4243
clearedSubsumedSpans []roachpb.Span
4344
}
4445

45-
// prepareSnapshot writes the unreplicated SST for the snapshot and clears disk data for subsumed replicas.
46-
func prepareSnapshot(ctx context.Context, input prepareSnapshotInput) (preparedSnapshot, error) {
46+
// prepareSnapApply writes the unreplicated SST for the snapshot and clears disk data for subsumed replicas.
47+
func prepareSnapApply(ctx context.Context, input prepareSnapApplyInput) (preparedSnapApply, error) {
4748
// Step 1: Write unreplicated SST
4849
unreplicatedSSTFile, clearedSpan, err := writeUnreplicatedSST(
4950
ctx, input.id, input.st, input.truncState, input.hardState, input.logSL,
5051
)
5152
if err != nil {
52-
return preparedSnapshot{}, err
53+
return preparedSnapApply{}, err
5354
}
5455
if err := input.writeSST(ctx, unreplicatedSSTFile.Data()); err != nil {
55-
return preparedSnapshot{}, err
56+
return preparedSnapApply{}, err
5657
}
5758

5859
var clearedSubsumedSpans []roachpb.Span
@@ -62,12 +63,12 @@ func prepareSnapshot(ctx context.Context, input prepareSnapshotInput) (preparedS
6263
input.desc, input.subsumedDescs,
6364
)
6465
if err != nil {
65-
return preparedSnapshot{}, err
66+
return preparedSnapApply{}, err
6667
}
6768
clearedSubsumedSpans = spans
6869
}
6970

70-
return preparedSnapshot{
71+
return preparedSnapApply{
7172
clearedSpan: clearedSpan,
7273
clearedSubsumedSpans: clearedSubsumedSpans,
7374
}, nil

0 commit comments

Comments
 (0)