From 863d38dfeebaceb69ce57cbba862102e10222256 Mon Sep 17 00:00:00 2001 From: Fabian Reinartz Date: Fri, 17 Mar 2017 15:56:19 +0100 Subject: [PATCH] Fix unreturned lock --- db.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/db.go b/db.go index 3f1d9c766..ec0f0a701 100644 --- a/db.go +++ b/db.go @@ -227,11 +227,13 @@ func (db *DB) run() { } func (db *DB) retentionCutoff() (bool, error) { - db.headmtx.RLock() - if db.opts.RetentionDuration == 0 { return false, nil } + + db.mtx.RLock() + defer db.mtx.RUnlock() + // We don't count the span covered by head blocks towards the // retention time as it generally makes up a fraction of it. if len(db.persisted) == 0 { @@ -241,8 +243,6 @@ func (db *DB) retentionCutoff() (bool, error) { last := db.persisted[len(db.persisted)-1] mint := last.Meta().MaxTime - int64(db.opts.RetentionDuration) - db.headmtx.RUnlock() - return retentionCutoff(db.dir, mint) }