mirror of
https://github.com/prometheus/prometheus.git
synced 2025-01-12 14:27:27 -08:00
Fix panic from db metrics (#7501)
Signed-off-by: Ganesh Vernekar <cs15btech11018@iith.ac.in>
This commit is contained in:
parent
b962029031
commit
e65e2e0dac
15
tsdb/db.go
15
tsdb/db.go
|
@ -569,13 +569,6 @@ func open(dir string, l log.Logger, r prometheus.Registerer, opts *Options, rngs
|
||||||
autoCompact: true,
|
autoCompact: true,
|
||||||
chunkPool: chunkenc.NewPool(),
|
chunkPool: chunkenc.NewPool(),
|
||||||
}
|
}
|
||||||
db.metrics = newDBMetrics(db, r)
|
|
||||||
|
|
||||||
maxBytes := opts.MaxBytes
|
|
||||||
if maxBytes < 0 {
|
|
||||||
maxBytes = 0
|
|
||||||
}
|
|
||||||
db.metrics.maxBytes.Set(float64(maxBytes))
|
|
||||||
|
|
||||||
if !opts.NoLockfile {
|
if !opts.NoLockfile {
|
||||||
absdir, err := filepath.Abs(dir)
|
absdir, err := filepath.Abs(dir)
|
||||||
|
@ -617,6 +610,14 @@ func open(dir string, l log.Logger, r prometheus.Registerer, opts *Options, rngs
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Register metrics after assigning the head block.
|
||||||
|
db.metrics = newDBMetrics(db, r)
|
||||||
|
maxBytes := opts.MaxBytes
|
||||||
|
if maxBytes < 0 {
|
||||||
|
maxBytes = 0
|
||||||
|
}
|
||||||
|
db.metrics.maxBytes.Set(float64(maxBytes))
|
||||||
|
|
||||||
if err := db.reload(); err != nil {
|
if err := db.reload(); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue