Skip to content

Commit

Permalink
Merge pull request #9167 from bdarnell/cli-debug-unreplicated
Browse files Browse the repository at this point in the history
cli: Include unreplicated data in `debug range-data`
  • Loading branch information
bdarnell authored Sep 7, 2016
2 parents 7517390 + 99408d8 commit e3ee5b3
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 5 deletions.
5 changes: 5 additions & 0 deletions cli/cliflags/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -349,4 +349,9 @@ defined in terms of multiples of this value.`,
Name: "undo",
Description: `Attempt to undo an earlier attempt to freeze the cluster.`,
}

Replicated = FlagInfo{
Name: "replicated",
Description: "Restrict scan to replicated data.",
}
)
1 change: 1 addition & 0 deletions cli/context.go
Original file line number Diff line number Diff line change
Expand Up @@ -144,4 +144,5 @@ type debugContext struct {
startKey, endKey engine.MVCCKey
values bool
sizes bool
replicated bool
}
7 changes: 4 additions & 3 deletions cli/debug.go
Original file line number Diff line number Diff line change
Expand Up @@ -152,8 +152,9 @@ var debugRangeDataCmd = &cobra.Command{
Use: "range-data [directory] range-id",
Short: "dump all the data in a range",
Long: `
Pretty-prints all keys and values in a range. This includes all data covered
by the consistency checker.
Pretty-prints all keys and values in a range. By default, includes unreplicated
state like the raft HardState. With --replicated, only includes data covered by
the consistency checker.
`,
RunE: runDebugRangeData,
}
Expand Down Expand Up @@ -181,7 +182,7 @@ func runDebugRangeData(cmd *cobra.Command, args []string) error {
return err
}

iter := storage.NewReplicaDataIterator(&desc, db, true)
iter := storage.NewReplicaDataIterator(&desc, db, debugCtx.replicated)
for ; iter.Valid(); iter.Next() {
if _, err := printKeyValue(engine.MVCCKeyValue{
Key: iter.Key(),
Expand Down
8 changes: 6 additions & 2 deletions cli/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,9 @@ var baseCtx = serverCtx.Context
var cliCtx = cliContext{Context: baseCtx}
var sqlCtx = sqlContext{cliContext: &cliCtx}
var debugCtx = debugContext{
startKey: engine.NilKey,
endKey: engine.MVCCKeyMax,
startKey: engine.NilKey,
endKey: engine.MVCCKeyMax,
replicated: false,
}

var cacheSize *bytesValue
Expand Down Expand Up @@ -404,6 +405,9 @@ func init() {
varFlag(f, (*mvccKey)(&debugCtx.endKey), cliflags.To)
boolFlag(f, &debugCtx.values, cliflags.Values, false)
boolFlag(f, &debugCtx.sizes, cliflags.Sizes, false)

f = debugRangeDataCmd.Flags()
boolFlag(f, &debugCtx.replicated, cliflags.Replicated, false)
}

boolFlag(versionCmd.Flags(), &versionIncludesDeps, cliflags.Deps, false)
Expand Down

0 comments on commit e3ee5b3

Please sign in to comment.