preallocate disk space during compaction also, add cleanup for failed compaction

This commit is contained in:
Chris Lu
2017-08-29 23:59:53 -07:00
parent f7c22f0159
commit 58344980e4
10 changed files with 92 additions and 17 deletions

View File

@@ -33,14 +33,16 @@ func runCompact(cmd *Command, args []string) bool {
return false
}
preallocate := *compactVolumePreallocate * (1 << 20)
vid := storage.VolumeId(*compactVolumeId)
v, err := storage.NewVolume(*compactVolumePath, *compactVolumeCollection, vid,
storage.NeedleMapInMemory, nil, nil, *compactVolumePreallocate*(1<<20))
storage.NeedleMapInMemory, nil, nil, preallocate)
if err != nil {
glog.Fatalf("Load Volume [ERROR] %s\n", err)
}
if *compactMethod == 0 {
if err = v.Compact(); err != nil {
if err = v.Compact(preallocate); err != nil {
glog.Fatalf("Compact Volume [ERROR] %s\n", err)
}
} else {