@@ -57,7 +57,8 @@ import (
5757 "github.com/spf13/cobra"
5858)
5959
60- var debugKeysCmd = & cobra.Command {
60+ // DebugKeysCmd dumps keys.
61+ var DebugKeysCmd = & cobra.Command {
6162 Use : "keys <directory>" ,
6263 Short : "dump all the keys in a store" ,
6364 Long : `
@@ -77,6 +78,11 @@ Create a ballast file to fill the store directory up to a given amount
7778 RunE : runDebugBallast ,
7879}
7980
81+ // PopulateRocksDBConfigHook is a callback set by CCL code.
82+ // It populates any needed fields in the RocksDBConfig.
83+ // It must do nothing in OSS code.
84+ var PopulateRocksDBConfigHook func (* engine.RocksDBConfig ) error
85+
8086func parseRangeID (arg string ) (roachpb.RangeID , error ) {
8187 rangeIDInt , err := strconv .ParseInt (arg , 10 , 64 )
8288 if err != nil {
@@ -95,19 +101,26 @@ func openExistingStore(dir string, stopper *stop.Stopper, readOnly bool) (*engin
95101 if err != nil {
96102 return nil , err
97103 }
98- db , err := engine .NewRocksDB (
99- engine.RocksDBConfig {
100- Settings : serverCfg .Settings ,
101- Dir : dir ,
102- MaxOpenFiles : maxOpenFiles ,
103- MustExist : true ,
104- ReadOnly : readOnly ,
105- },
106- cache ,
107- )
104+
105+ cfg := engine.RocksDBConfig {
106+ Settings : serverCfg .Settings ,
107+ Dir : dir ,
108+ MaxOpenFiles : maxOpenFiles ,
109+ MustExist : true ,
110+ ReadOnly : readOnly ,
111+ }
112+
113+ if PopulateRocksDBConfigHook != nil {
114+ if err := PopulateRocksDBConfigHook (& cfg ); err != nil {
115+ return nil , err
116+ }
117+ }
118+
119+ db , err := engine .NewRocksDB (cfg , cache )
108120 if err != nil {
109121 return nil , err
110122 }
123+
111124 stopper .AddCloser (db )
112125 return db , nil
113126}
@@ -219,7 +232,8 @@ func runDebugBallast(cmd *cobra.Command, args []string) error {
219232 return nil
220233}
221234
222- var debugRangeDataCmd = & cobra.Command {
235+ // DebugRangeDataCmd dumps data for a range.
236+ var DebugRangeDataCmd = & cobra.Command {
223237 Use : "range-data <directory> <range id>" ,
224238 Short : "dump all the data in a range" ,
225239 Long : `
@@ -268,7 +282,8 @@ func runDebugRangeData(cmd *cobra.Command, args []string) error {
268282 return nil
269283}
270284
271- var debugRangeDescriptorsCmd = & cobra.Command {
285+ // DebugRangeDescriptorsCmd prints range descriptors.
286+ var DebugRangeDescriptorsCmd = & cobra.Command {
272287 Use : "range-descriptors <directory>" ,
273288 Short : "print all range descriptors in a store" ,
274289 Long : `
@@ -526,7 +541,8 @@ Decode a hexadecimal-encoded key and pretty-print it. For example:
526541 },
527542}
528543
529- var debugRaftLogCmd = & cobra.Command {
544+ // DebugRaftLogCmd prints raft log entries.
545+ var DebugRaftLogCmd = & cobra.Command {
530546 Use : "raft-log <directory> <range id>" ,
531547 Short : "print the raft log for a range" ,
532548 Long : `
@@ -607,7 +623,8 @@ func runDebugRaftLog(cmd *cobra.Command, args []string) error {
607623 return db .Iterate (start , end , printRaftLogEntry )
608624}
609625
610- var debugGCCmd = & cobra.Command {
626+ // DebugGCCmd print GC information.
627+ var DebugGCCmd = & cobra.Command {
611628 Use : "estimate-gc <directory> [range id]" ,
612629 Short : "find out what a GC run would do" ,
613630 Long : `
@@ -693,7 +710,8 @@ func runDebugGCCmd(cmd *cobra.Command, args []string) error {
693710 return nil
694711}
695712
696- var debugCheckStoreCmd = & cobra.Command {
713+ // DebugCheckStoreCmd checks store consistency.
714+ var DebugCheckStoreCmd = & cobra.Command {
697715 Use : "check-store <directory>" ,
698716 Short : "consistency check for a single store" ,
699717 Long : `
@@ -850,6 +868,7 @@ as 'ldb'.
850868https://github.com/facebook/rocksdb/wiki/Administration-and-Data-Access-Tool#ldb-tool
851869` ,
852870 // LDB does its own flag parsing.
871+ // TODO(mberhault): support encrypted stores.
853872 DisableFlagParsing : true ,
854873 Run : func (cmd * cobra.Command , args []string ) {
855874 engine .RunLDB (args )
@@ -869,7 +888,8 @@ Output environment variables that influence configuration.
869888 },
870889}
871890
872- var debugCompactCmd = & cobra.Command {
891+ // DebugCompactCmd compacts sstables.
892+ var DebugCompactCmd = & cobra.Command {
873893 Use : "compact <directory>" ,
874894 Short : "compact the sstables in a store" ,
875895 Long : `
@@ -910,7 +930,8 @@ func runDebugCompact(cmd *cobra.Command, args []string) error {
910930 return nil
911931}
912932
913- var debugSSTablesCmd = & cobra.Command {
933+ // DebugSSTablesCmd lists sstables.
934+ var DebugSSTablesCmd = & cobra.Command {
914935 Use : "sstables <directory>" ,
915936 Short : "list the sstables in a store" ,
916937 Long : `
@@ -1097,23 +1118,28 @@ func init() {
10971118 "only write to the WAL, not to sstables" )
10981119}
10991120
1100- var debugCmds = []* cobra.Command {
1121+ // DebugCmdsForRocksDB lists debug commands that access rocksdb.
1122+ var DebugCmdsForRocksDB = []* cobra.Command {
1123+ DebugCheckStoreCmd ,
1124+ DebugCompactCmd ,
1125+ DebugGCCmd ,
1126+ DebugKeysCmd ,
1127+ DebugRaftLogCmd ,
1128+ DebugRangeDataCmd ,
1129+ DebugRangeDescriptorsCmd ,
1130+ DebugSSTablesCmd ,
1131+ }
1132+
1133+ // All other debug commands go here.
1134+ var debugCmds = append (DebugCmdsForRocksDB ,
11011135 debugBallastCmd ,
1102- debugKeysCmd ,
1103- debugRangeDataCmd ,
1104- debugRangeDescriptorsCmd ,
11051136 debugDecodeKeyCmd ,
1106- debugRaftLogCmd ,
1107- debugGCCmd ,
1108- debugCheckStoreCmd ,
11091137 debugRocksDBCmd ,
1110- debugCompactCmd ,
1111- debugSSTablesCmd ,
11121138 debugGossipValuesCmd ,
11131139 debugSyncTestCmd ,
11141140 debugEnvCmd ,
11151141 debugZipCmd ,
1116- }
1142+ )
11171143
11181144var debugCmd = & cobra.Command {
11191145 Use : "debug [command]" ,
0 commit comments