From 9275ddc5494a0f4f78fd315cad6e8607a2bb5f71 Mon Sep 17 00:00:00 2001 From: mizeng Date: Fri, 21 Jun 2019 13:26:45 +0800 Subject: [PATCH] avoid dead loop in boltdb_index_client when obtain file lock Signed-off-by: mizeng --- pkg/chunk/local/boltdb_index_client.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pkg/chunk/local/boltdb_index_client.go b/pkg/chunk/local/boltdb_index_client.go index 55f5416212a..624e6ff4eda 100644 --- a/pkg/chunk/local/boltdb_index_client.go +++ b/pkg/chunk/local/boltdb_index_client.go @@ -140,7 +140,8 @@ func (b *boltIndexClient) getDB(name string) (*bbolt.DB, error) { } // Open the database. - db, err := bbolt.Open(path.Join(b.cfg.Directory, name), 0666, nil) + // Set Timeout to avoid obtaining file lock wait indefinitely. + db, err := bbolt.Open(path.Join(b.cfg.Directory, name), 0666, &bbolt.Options{Timeout: 5 * time.Second}) if err != nil { return nil, err }