Skip to content

Commit

Permalink
cli: parse values for more range keys
Browse files Browse the repository at this point in the history
Add those which were not decoded while looking at cockroachdb#7389.
  • Loading branch information
tbg committed Jun 23, 2016
1 parent 4839efe commit 9a17c45
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 12 deletions.
16 changes: 16 additions & 0 deletions cli/debug.go
Original file line number Diff line number Diff line change
Expand Up @@ -300,6 +300,22 @@ func tryRangeIDKey(kv engine.MVCCKeyValue) (string, error) {
case bytes.Equal(suffix, keys.LocalRangeStatsSuffix):
msg = &enginepb.MVCCStats{}

case bytes.Equal(suffix, keys.LocalRaftHardStateSuffix):
msg = &raftpb.HardState{}

case bytes.Equal(suffix, keys.LocalRaftLastIndexSuffix):
i, err := value.GetInt()
if err != nil {
return "", err
}
return fmt.Sprintf("%d", i), nil

case bytes.Equal(suffix, keys.LocalRangeLastVerificationTimestampSuffix):
msg = &hlc.Timestamp{}

case bytes.Equal(suffix, keys.LocalRangeLastReplicaGCTimestampSuffix):
msg = &hlc.Timestamp{}

default:
return "", fmt.Errorf("unknown raft id key %s", suffix)
}
Expand Down
8 changes: 4 additions & 4 deletions keys/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,17 +114,17 @@ var (
// together or individually in a single scan.
localRangeIDUnreplicatedInfix = []byte("u")
// localRaftHardStateSuffix is the Suffix for the raft HardState.
localRaftHardStateSuffix = []byte("rfth")
LocalRaftHardStateSuffix = []byte("rfth")
// localRaftLastIndexSuffix is the suffix for raft's last index.
localRaftLastIndexSuffix = []byte("rfti")
LocalRaftLastIndexSuffix = []byte("rfti")
// LocalRaftLogSuffix is the suffix for the raft log.
LocalRaftLogSuffix = []byte("rftl")
// localRangeLastReplicaGCTimestampSuffix is the suffix for a range's
// last replica GC timestamp (for GC of old replicas).
localRangeLastReplicaGCTimestampSuffix = []byte("rlrt")
LocalRangeLastReplicaGCTimestampSuffix = []byte("rlrt")
// localRangeLastVerificationTimestampSuffix is the suffix for a range's
// last verification timestamp (for checking integrity of on-disk data).
localRangeLastVerificationTimestampSuffix = []byte("rlvt")
LocalRangeLastVerificationTimestampSuffix = []byte("rlvt")

// LocalRangePrefix is the prefix identifying per-range data indexed
// by range key (either start key, or some key in the range). The
Expand Down
8 changes: 4 additions & 4 deletions keys/keys.go
Original file line number Diff line number Diff line change
Expand Up @@ -218,13 +218,13 @@ func MakeRangeIDUnreplicatedKey(rangeID roachpb.RangeID, suffix roachpb.RKey, de

// RaftHardStateKey returns a system-local key for a Raft HardState.
func RaftHardStateKey(rangeID roachpb.RangeID) roachpb.Key {
return MakeRangeIDUnreplicatedKey(rangeID, localRaftHardStateSuffix, nil)
return MakeRangeIDUnreplicatedKey(rangeID, LocalRaftHardStateSuffix, nil)
}

// RaftLastIndexKey returns a system-local key for the last index of the
// Raft log.
func RaftLastIndexKey(rangeID roachpb.RangeID) roachpb.Key {
return MakeRangeIDUnreplicatedKey(rangeID, localRaftLastIndexSuffix, nil)
return MakeRangeIDUnreplicatedKey(rangeID, LocalRaftLastIndexSuffix, nil)
}

// RaftLogPrefix returns the system-local prefix shared by all entries
Expand All @@ -243,13 +243,13 @@ func RaftLogKey(rangeID roachpb.RangeID, logIndex uint64) roachpb.Key {
// RangeLastReplicaGCTimestampKey returns a range-local key for
// the range's last replica GC timestamp.
func RangeLastReplicaGCTimestampKey(rangeID roachpb.RangeID) roachpb.Key {
return MakeRangeIDUnreplicatedKey(rangeID, localRangeLastReplicaGCTimestampSuffix, nil)
return MakeRangeIDUnreplicatedKey(rangeID, LocalRangeLastReplicaGCTimestampSuffix, nil)
}

// RangeLastVerificationTimestampKey returns a range-local key for
// the range's last verification timestamp.
func RangeLastVerificationTimestampKey(rangeID roachpb.RangeID) roachpb.Key {
return MakeRangeIDUnreplicatedKey(rangeID, localRangeLastVerificationTimestampSuffix, nil)
return MakeRangeIDUnreplicatedKey(rangeID, LocalRangeLastVerificationTimestampSuffix, nil)
}

// MakeRangeKey creates a range-local key based on the range
Expand Down
8 changes: 4 additions & 4 deletions keys/printer.go
Original file line number Diff line number Diff line change
Expand Up @@ -130,17 +130,17 @@ var (
}{
{name: "AbortCache", suffix: LocalAbortCacheSuffix, ppFunc: abortCacheKeyPrint, psFunc: abortCacheKeyParse},
{name: "RaftTombstone", suffix: LocalRaftTombstoneSuffix},
{name: "RaftHardState", suffix: localRaftHardStateSuffix},
{name: "RaftHardState", suffix: LocalRaftHardStateSuffix},
{name: "RaftAppliedIndex", suffix: LocalRaftAppliedIndexSuffix},
{name: "LeaseAppliedIndex", suffix: LocalLeaseAppliedIndexSuffix},
{name: "RaftLog", suffix: LocalRaftLogSuffix,
ppFunc: raftLogKeyPrint,
psFunc: raftLogKeyParse,
},
{name: "RaftTruncatedState", suffix: LocalRaftTruncatedStateSuffix},
{name: "RaftLastIndex", suffix: localRaftLastIndexSuffix},
{name: "RangeLastReplicaGCTimestamp", suffix: localRangeLastReplicaGCTimestampSuffix},
{name: "RangeLastVerificationTimestamp", suffix: localRangeLastVerificationTimestampSuffix},
{name: "RaftLastIndex", suffix: LocalRaftLastIndexSuffix},
{name: "RangeLastReplicaGCTimestamp", suffix: LocalRangeLastReplicaGCTimestampSuffix},
{name: "RangeLastVerificationTimestamp", suffix: LocalRangeLastVerificationTimestampSuffix},
{name: "RangeLeaderLease", suffix: LocalRangeLeaderLeaseSuffix},
{name: "RangeStats", suffix: LocalRangeStatsSuffix},
}
Expand Down

0 comments on commit 9a17c45

Please sign in to comment.