From 29b19a22934008d7f0dfed8589aa58240afabff4 Mon Sep 17 00:00:00 2001 From: Pierre Fersing Date: Mon, 11 Apr 2016 12:11:05 +0200 Subject: [PATCH] Fix deadlock in tsm1/file_store --- tsdb/engine/tsm1/file_store.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tsdb/engine/tsm1/file_store.go b/tsdb/engine/tsm1/file_store.go index 6024d308ca..6acb2da7a8 100644 --- a/tsdb/engine/tsm1/file_store.go +++ b/tsdb/engine/tsm1/file_store.go @@ -514,15 +514,14 @@ func (f *FileStore) BlockCount(path string, idx int) int { // locations returns the files and index blocks for a key and time. ascending indicates // whether the key will be scan in ascending time order or descenging time order. +// This function assumes the read-lock has been taken. func (f *FileStore) locations(key string, t int64, ascending bool) []location { var locations []location - f.mu.RLock() filesSnapshot := make([]TSMFile, len(f.files)) for i := range f.files { filesSnapshot[i] = f.files[i] } - f.mu.RUnlock() var entries []IndexEntry for _, fd := range filesSnapshot { @@ -617,6 +616,7 @@ type location struct { } // newKeyCursor returns a new instance of KeyCursor. +// This function assumes the read-lock has been taken. func newKeyCursor(fs *FileStore, key string, t int64, ascending bool) *KeyCursor { c := &KeyCursor{ key: key,