From e6d6acd261911701998651123e2cbbe53be4ab5a Mon Sep 17 00:00:00 2001 From: Paul Lorenz Date: Wed, 24 Jun 2020 14:06:20 -0400 Subject: [PATCH] Don't wait forever for a DB lock --- controller/db/db.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/controller/db/db.go b/controller/db/db.go index 2a5fb2fcb..abc1952f8 100644 --- a/controller/db/db.go +++ b/controller/db/db.go @@ -30,7 +30,11 @@ type Db struct { } func Open(path string) (*Db, error) { - db, err := bbolt.Open(path, 0600, nil) + // Only wait 1 second if database file can't be locked, as it most likely means another controller is running + options := *bbolt.DefaultOptions + options.Timeout = time.Second + + db, err := bbolt.Open(path, 0600, &options) if err != nil { return nil, fmt.Errorf("unable to open controller database [%s] (%s)", path, err) }