mirror of
https://github.com/prometheus/prometheus.git
synced 2024-12-26 06:04:05 -08:00
Correctly close compacted blocks.
This commit is contained in:
parent
55a9b5428a
commit
04783831e2
|
@ -163,6 +163,8 @@ func (c *compactor) Compact(dirs ...string) (err error) {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
defer b.Close()
|
||||||
|
|
||||||
blocks = append(blocks, b)
|
blocks = append(blocks, b)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
13
db.go
13
db.go
|
@ -334,6 +334,9 @@ func (db *DB) reloadBlocks() error {
|
||||||
db.mtx.Lock()
|
db.mtx.Lock()
|
||||||
defer db.mtx.Unlock()
|
defer db.mtx.Unlock()
|
||||||
|
|
||||||
|
db.headmtx.Lock()
|
||||||
|
defer db.headmtx.Unlock()
|
||||||
|
|
||||||
dirs, err := blockDirs(db.dir)
|
dirs, err := blockDirs(db.dir)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return errors.Wrap(err, "find blocks")
|
return errors.Wrap(err, "find blocks")
|
||||||
|
@ -355,17 +358,17 @@ func (db *DB) reloadBlocks() error {
|
||||||
|
|
||||||
for i, meta := range metas {
|
for i, meta := range metas {
|
||||||
b, ok := db.seqBlocks[meta.Sequence]
|
b, ok := db.seqBlocks[meta.Sequence]
|
||||||
if !ok {
|
// if !ok {
|
||||||
return errors.Errorf("missing block for sequence %d", meta.Sequence)
|
// return errors.Errorf("missing block for sequence %d", meta.Sequence)
|
||||||
}
|
// }
|
||||||
|
|
||||||
if meta.Compaction.Generation == 0 {
|
if meta.Compaction.Generation == 0 {
|
||||||
if meta.ULID != b.Meta().ULID {
|
if ok && meta.ULID != b.Meta().ULID {
|
||||||
return errors.Errorf("head block ULID changed unexpectedly")
|
return errors.Errorf("head block ULID changed unexpectedly")
|
||||||
}
|
}
|
||||||
heads = append(heads, b.(*headBlock))
|
heads = append(heads, b.(*headBlock))
|
||||||
} else {
|
} else {
|
||||||
if meta.ULID != b.Meta().ULID {
|
if ok && meta.ULID != b.Meta().ULID {
|
||||||
if err := b.Close(); err != nil {
|
if err := b.Close(); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue