mirror of
https://github.com/prometheus/prometheus.git
synced 2024-12-26 22:19:40 -08:00
commit
296faccf2f
21
db.go
21
db.go
|
@ -379,6 +379,27 @@ func (db *DB) compact() (changes bool, err error) {
|
||||||
}
|
}
|
||||||
changes = true
|
changes = true
|
||||||
|
|
||||||
|
// close blocks in plan so that we can remove files.
|
||||||
|
var blocks []*Block
|
||||||
|
db.mtx.Lock()
|
||||||
|
oldBlocks := db.blocks
|
||||||
|
for _, b := range oldBlocks {
|
||||||
|
keep := true
|
||||||
|
for _, pd := range plan {
|
||||||
|
if pd == b.Dir() {
|
||||||
|
keep = false
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if keep {
|
||||||
|
blocks = append(blocks, b)
|
||||||
|
} else {
|
||||||
|
b.Close()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
db.blocks = blocks
|
||||||
|
db.mtx.Unlock()
|
||||||
|
|
||||||
for _, pd := range plan {
|
for _, pd := range plan {
|
||||||
if err := os.RemoveAll(pd); err != nil {
|
if err := os.RemoveAll(pd); err != nil {
|
||||||
return changes, errors.Wrap(err, "delete compacted block")
|
return changes, errors.Wrap(err, "delete compacted block")
|
||||||
|
|
Loading…
Reference in a new issue