From 23ffb81da005d4f65a9567ac406adf3ed4824feb Mon Sep 17 00:00:00 2001 From: iyear Date: Tue, 30 Aug 2022 09:25:39 +0800 Subject: [PATCH] fix(kv): set timeout for bolt db --- pkg/storage/kv/bolt/bolt.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/pkg/storage/kv/bolt/bolt.go b/pkg/storage/kv/bolt/bolt.go index 2714cbc..6959807 100644 --- a/pkg/storage/kv/bolt/bolt.go +++ b/pkg/storage/kv/bolt/bolt.go @@ -8,6 +8,7 @@ import ( "github.com/mitchellh/mapstructure" "go.etcd.io/bbolt" "os" + "time" ) type Options struct { @@ -35,7 +36,11 @@ func New(options map[string]interface{}) (*Bolt, error) { return nil, err } - db, err := bbolt.Open(ops.Path, os.ModePerm, bbolt.DefaultOptions) + db, err := bbolt.Open(ops.Path, os.ModePerm, &bbolt.Options{ + Timeout: time.Second, + NoGrowSync: false, + FreelistType: bbolt.FreelistArrayType, + }) if err != nil { return nil, err }