mirror of
https://gitlab.com/pulsechaincom/prysm-pulse.git
synced 2024-12-25 12:57:18 +00:00
Fixed hang when multiple processes open same DB (#1116)
* Fixed hang when multiple processes open same DB * fixed error check and message * removed punctuation on error message
This commit is contained in:
parent
4f316d6ed0
commit
a0c540d780
@ -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
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user