mirror of
https://github.com/prometheus/prometheus.git
synced 2025-03-05 20:59:13 -08:00
Fix unreturned lock
This commit is contained in:
parent
d0770302ed
commit
863d38dfee
8
db.go
8
db.go
|
@ -227,11 +227,13 @@ func (db *DB) run() {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (db *DB) retentionCutoff() (bool, error) {
|
func (db *DB) retentionCutoff() (bool, error) {
|
||||||
db.headmtx.RLock()
|
|
||||||
|
|
||||||
if db.opts.RetentionDuration == 0 {
|
if db.opts.RetentionDuration == 0 {
|
||||||
return false, nil
|
return false, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
db.mtx.RLock()
|
||||||
|
defer db.mtx.RUnlock()
|
||||||
|
|
||||||
// We don't count the span covered by head blocks towards the
|
// We don't count the span covered by head blocks towards the
|
||||||
// retention time as it generally makes up a fraction of it.
|
// retention time as it generally makes up a fraction of it.
|
||||||
if len(db.persisted) == 0 {
|
if len(db.persisted) == 0 {
|
||||||
|
@ -241,8 +243,6 @@ func (db *DB) retentionCutoff() (bool, error) {
|
||||||
last := db.persisted[len(db.persisted)-1]
|
last := db.persisted[len(db.persisted)-1]
|
||||||
mint := last.Meta().MaxTime - int64(db.opts.RetentionDuration)
|
mint := last.Meta().MaxTime - int64(db.opts.RetentionDuration)
|
||||||
|
|
||||||
db.headmtx.RUnlock()
|
|
||||||
|
|
||||||
return retentionCutoff(db.dir, mint)
|
return retentionCutoff(db.dir, mint)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue