Close blocks before overwriting with compacted one
This prevents the meta.json file of a compacted block to be overwritten with data of the old block.
This commit is contained in:
parent
ac5229e1b4
commit
f556036037
9
db.go
9
db.go
|
@ -264,6 +264,12 @@ func (db *DB) compact(i, j int) error {
|
|||
db.mtx.Lock()
|
||||
defer db.mtx.Unlock()
|
||||
|
||||
for _, b := range blocks {
|
||||
if err := b.Close(); err != nil {
|
||||
return errors.Wrap(err, "close old block")
|
||||
}
|
||||
}
|
||||
|
||||
if err := renameDir(tmpdir, dir); err != nil {
|
||||
return errors.Wrap(err, "rename dir")
|
||||
}
|
||||
|
@ -273,9 +279,6 @@ func (db *DB) compact(i, j int) error {
|
|||
db.persisted = append(db.persisted, pb)
|
||||
|
||||
for i, b := range blocks {
|
||||
if err := b.Close(); err != nil {
|
||||
return errors.Wrap(err, "close old block")
|
||||
}
|
||||
if i > 0 {
|
||||
if err := os.RemoveAll(b.Dir()); err != nil {
|
||||
return errors.Wrap(err, "removing old block")
|
||||
|
|
Loading…
Reference in New Issue