forked from TrueCloudLab/frostfs-node
[#316] locode/boltdb: Add default timeout to open underlying BoltDB instance
Set timeout option of BoltDB Open operation to 3s in order to prevent indefinite waiting for file lock. Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
This commit is contained in:
parent
97264acb26
commit
04b06ba539
2 changed files with 6 additions and 0 deletions
|
@ -11,6 +11,8 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
// Open opens underlying BoltDB instance.
|
// Open opens underlying BoltDB instance.
|
||||||
|
//
|
||||||
|
// Timeout of BoltDB opening is 3s (only for Linux or Darwin).
|
||||||
func (db *DB) Open() error {
|
func (db *DB) Open() error {
|
||||||
// copy-paste from metabase:
|
// copy-paste from metabase:
|
||||||
// consider universal Open/Close for BoltDB wrappers
|
// consider universal Open/Close for BoltDB wrappers
|
||||||
|
|
|
@ -2,6 +2,7 @@ package locodebolt
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"os"
|
"os"
|
||||||
|
"time"
|
||||||
|
|
||||||
"go.etcd.io/bbolt"
|
"go.etcd.io/bbolt"
|
||||||
)
|
)
|
||||||
|
@ -18,5 +19,8 @@ type options struct {
|
||||||
func defaultOpts() *options {
|
func defaultOpts() *options {
|
||||||
return &options{
|
return &options{
|
||||||
mode: os.ModePerm, // 0777
|
mode: os.ModePerm, // 0777
|
||||||
|
boltOpts: &bbolt.Options{
|
||||||
|
Timeout: 3 * time.Second,
|
||||||
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue