From 604661be3d40869a257326c548643512fc81bb42 Mon Sep 17 00:00:00 2001 From: nsa Date: Thu, 1 Aug 2019 19:30:07 -0400 Subject: [PATCH 1/2] build: update bbolt to v1.3.3 This commit updates the bbolt dependency to v1.3.3 so that we can use the NoFreelistSync option without triggering a panic in case a rollback occurs. --- go.mod | 2 +- go.sum | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/go.mod b/go.mod index 1145245..7e79c76 100644 --- a/go.mod +++ b/go.mod @@ -6,7 +6,7 @@ require ( github.com/btcsuite/btcutil v0.0.0-20190425235716-9e5f4b9a998d github.com/btcsuite/golangcrypto v0.0.0-20150304025918-53f62d9b43e8 github.com/btcsuite/websocket v0.0.0-20150119174127-31079b680792 - github.com/coreos/bbolt v1.3.2 + github.com/coreos/bbolt v1.3.3 github.com/davecgh/go-spew v1.1.1 github.com/golang/protobuf v1.2.0 github.com/jessevdk/go-flags v1.4.0 diff --git a/go.sum b/go.sum index 2410dd9..9b576b1 100644 --- a/go.sum +++ b/go.sum @@ -35,6 +35,8 @@ github.com/coreos/bbolt v0.0.0-20180223184059-7ee3ded59d4835e10f3e7d0f7603c42aa5 github.com/coreos/bbolt v0.0.0-20180223184059-7ee3ded59d4835e10f3e7d0f7603c42aa5e83820/go.mod h1:iRUV2dpdMOn7Bo10OQBFzIJO9kkE559Wcmn+qkEiiKk= github.com/coreos/bbolt v1.3.2 h1:wZwiHHUieZCquLkDL0B8UhzreNWsPHooDAG3q34zk0s= github.com/coreos/bbolt v1.3.2/go.mod h1:iRUV2dpdMOn7Bo10OQBFzIJO9kkE559Wcmn+qkEiiKk= +github.com/coreos/bbolt v1.3.3 h1:n6AiVyVRKQFNb6mJlwESEvvLoDyiTzXX7ORAUlkeBdY= +github.com/coreos/bbolt v1.3.3/go.mod h1:iRUV2dpdMOn7Bo10OQBFzIJO9kkE559Wcmn+qkEiiKk= github.com/davecgh/go-spew v0.0.0-20171005155431-ecdeabc65495 h1:6IyqGr3fnd0tM3YxipK27TUskaOVUjU2nG45yzwcQKY= github.com/davecgh/go-spew v0.0.0-20171005155431-ecdeabc65495/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= From e809748b1e5563ef90ec04246762e7b67f283706 Mon Sep 17 00:00:00 2001 From: nsa Date: Thu, 1 Aug 2019 22:15:53 -0400 Subject: [PATCH 2/2] bdb: specify freelist options by default This commit specifies two bbolt options when opening the bbolt db. This reduces heap pressure in case there are a lot of pages on the freelist. --- walletdb/bdb/db.go | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/walletdb/bdb/db.go b/walletdb/bdb/db.go index bf34e7a..ab611ba 100644 --- a/walletdb/bdb/db.go +++ b/walletdb/bdb/db.go @@ -344,6 +344,13 @@ func openDB(dbPath string, create bool) (walletdb.DB, error) { return nil, walletdb.ErrDbDoesNotExist } - boltDB, err := bbolt.Open(dbPath, 0600, nil) + // Specify bbolt freelist options to reduce heap pressure in case the + // freelist grows to be very large. + options := &bbolt.Options{ + NoFreelistSync: true, + FreelistType: bbolt.FreelistMapType, + } + + boltDB, err := bbolt.Open(dbPath, 0600, options) return (*db)(boltDB), convertErr(err) }