Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
jeffrey-xiao committed Jul 17, 2019
1 parent d823a03 commit ad5b8b2
Show file tree
Hide file tree
Showing 11 changed files with 526 additions and 58 deletions.
5 changes: 5 additions & 0 deletions pkg/keys/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,11 @@ var (
// last verification timestamp (for checking integrity of on-disk data).
// Note: DEPRECATED.
LocalRangeLastVerificationTimestampSuffixDeprecated = []byte("rlvt")
// LocalRangeSSTSnapshotInProgress is the UUID of the snapshot in progress,
// if any. If this key is set, the replica must finish processing the
// snapshot by ingesting the SSTs of the snapshot before performing any other
// action.
LocalRangeSSTSnapshotInProgressSuffix = []byte("rssp")
// LocalRangePrefix is the prefix identifying per-range data indexed
// by range key (either start key, or some key in the range). The
// key is appended to this prefix, encoded using EncodeBytes. The
Expand Down
12 changes: 12 additions & 0 deletions pkg/keys/keys.go
Original file line number Diff line number Diff line change
Expand Up @@ -350,6 +350,12 @@ func RangeLastVerificationTimestampKeyDeprecated(rangeID roachpb.RangeID) roachp
return MakeRangeIDPrefixBuf(rangeID).RangeLastVerificationTimestampKeyDeprecated()
}

// RangeSSTSnapshotInProgress returns a range-local key for the snapshot in
// progress, in any.
func RangeSSTSnapshotInProgress(rangeID roachpb.RangeID) roachpb.Key {
return MakeRangeIDPrefixBuf(rangeID).RangeSSTSnapshotInProgress()
}

// MakeRangeKey creates a range-local key based on the range
// start key, metadata key suffix, and optional detail (e.g. the
// transaction ID for a txn record, etc.).
Expand Down Expand Up @@ -975,3 +981,9 @@ func (b RangeIDPrefixBuf) RangeLastReplicaGCTimestampKey() roachpb.Key {
func (b RangeIDPrefixBuf) RangeLastVerificationTimestampKeyDeprecated() roachpb.Key {
return append(b.unreplicatedPrefix(), LocalRangeLastVerificationTimestampSuffixDeprecated...)
}

// RangeSSTSnapshotInProgress returns a range-local key for the snapshot in
// progress, in any.
func (b RangeIDPrefixBuf) RangeSSTSnapshotInProgress() roachpb.Key {
return append(b.unreplicatedPrefix(), LocalRangeSSTSnapshotInProgressSuffix...)
}
1 change: 1 addition & 0 deletions pkg/keys/printer.go
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@ var (
{name: "RaftTombstone", suffix: LocalRaftTombstoneSuffix},
{name: "RaftHardState", suffix: LocalRaftHardStateSuffix},
{name: "RangeAppliedState", suffix: LocalRangeAppliedStateSuffix},
{name: "RangeSSTSnapshotInProgress", suffix: LocalRangeSSTSnapshotInProgressSuffix},
{name: "RaftAppliedIndex", suffix: LocalRaftAppliedIndexLegacySuffix},
{name: "LeaseAppliedIndex", suffix: LocalLeaseAppliedIndexLegacySuffix},
{name: "RaftLog", suffix: LocalRaftLogSuffix,
Expand Down
228 changes: 192 additions & 36 deletions pkg/roachpb/internal_raft.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions pkg/roachpb/internal_raft.proto
Original file line number Diff line number Diff line change
Expand Up @@ -51,3 +51,9 @@ message RaftSnapshotData {
// roundtripping through memory.
repeated bytes log_entries = 3;
}

// SSTSnapshotInProgressData is the data needed to process an in-progress snapshot.
message SSTSnapshotInProgressData {
// The uuid of the in-progress snapshot.
optional bytes uuid = 1 [(gogoproto.customname) = "UUID"];
}
2 changes: 2 additions & 0 deletions pkg/storage/client_raft_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ import (
"github.com/cockroachdb/cockroach/pkg/util/protoutil"
"github.com/cockroachdb/cockroach/pkg/util/stop"
"github.com/cockroachdb/cockroach/pkg/util/timeutil"
"github.com/cockroachdb/cockroach/pkg/util/uuid"
"github.com/pkg/errors"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
Expand Down Expand Up @@ -1070,6 +1071,7 @@ func TestFailedSnapshotFillsReservation(t *testing.T) {
RangeSize: 100,
State: storagepb.ReplicaState{Desc: rep.Desc()},
}
header.RaftMessageRequest.Message.Snapshot.Data = uuid.UUID{}.GetBytes()
// Cause this stream to return an error as soon as we ask it for something.
// This injects an error into HandleSnapshotStream when we try to send the
// "snapshot accepted" message.
Expand Down
Loading

0 comments on commit ad5b8b2

Please sign in to comment.