diff --git a/beacon-chain/db/db.go b/beacon-chain/db/db.go index db065b1c8..be8c82887 100644 --- a/beacon-chain/db/db.go +++ b/beacon-chain/db/db.go @@ -3,8 +3,9 @@ package db import ( "os" "path" - + "time" "github.com/boltdb/bolt" + "errors" ) // BeaconDB manages the data layer of the beacon chain implementation. @@ -46,8 +47,11 @@ func NewDB(dirPath string) (*BeaconDB, error) { return nil, err } datafile := path.Join(dirPath, "beaconchain.db") - boltDB, err := bolt.Open(datafile, 0600, nil) + boltDB, err := bolt.Open(datafile, 0600, &bolt.Options{Timeout: 1 * time.Second}) if err != nil { + if err == bolt.ErrTimeout { + return nil, errors.New("cannot obtain database lock, database may be in use by another process") + } return nil, err }