Skip to content
This repository was archived by the owner on Aug 13, 2019. It is now read-only.

Commit 7c89db0

Browse files
author
Krasi Georgiev
committed
first draft
Signed-off-by: Krasi Georgiev <[email protected]>
1 parent def6e5a commit 7c89db0

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

cmd/tsdb/main.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,8 @@ func main() {
4646
benchSamplesFile = benchWriteCmd.Arg("file", "input file with samples data, default is (../../testdata/20k.series)").Default("../../testdata/20k.series").String()
4747
listCmd = cli.Command("ls", "list db blocks")
4848
listPath = listCmd.Arg("db path", "database path (default is benchout/storage)").Default("benchout/storage").String()
49+
scanCmd = cli.Command("scan", "scans the db and lists corrupted blocks")
50+
scanPath = scanCmd.Arg("dir", "database path (default is current dir ./)").Default("./").String()
4951
)
5052

5153
switch kingpin.MustParse(cli.Parse(os.Args[1:])) {
@@ -62,6 +64,12 @@ func main() {
6264
exitWithError(err)
6365
}
6466
printBlocks(db.Blocks())
67+
case scanCmd.FullCommand():
68+
corrupted, err := tsdb.Scan(*scanPath)
69+
if err != nil {
70+
exitWithError(err)
71+
}
72+
// list corrupted blocks with date ranges and prompt: "Do you want to delete corrupted blocks N,y ?"
6573
}
6674
flag.CommandLine.Set("log.level", "debug")
6775
}

db.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -250,6 +250,11 @@ func (db *DB) Dir() string {
250250
return db.dir
251251
}
252252

253+
// Scan checks the integrity of the db for a given directory and returns a list of unreadable blocks that can be deleted to allow a clean startup.
254+
func Scan(dir string) ([]string, error) {
255+
return nil, nil
256+
}
257+
253258
func (db *DB) run() {
254259
defer close(db.donec)
255260

0 commit comments

Comments
 (0)