diff --git a/chainntnfs/bitcoindnotify/bitcoind.go b/chainntnfs/bitcoindnotify/bitcoind.go index f0547e4df..8bcf8872b 100644 --- a/chainntnfs/bitcoindnotify/bitcoind.go +++ b/chainntnfs/bitcoindnotify/bitcoind.go @@ -139,6 +139,7 @@ func (b *BitcoindNotifier) Stop() error { // Shutdown the rpc client, this gracefully disconnects from bitcoind, // and cleans up all related resources. b.chainConn.Stop() + b.chainConn.WaitForShutdown() close(b.quit) b.wg.Wait() diff --git a/chainntnfs/btcdnotify/btcd.go b/chainntnfs/btcdnotify/btcd.go index 1bf63f1e6..bcbfa571a 100644 --- a/chainntnfs/btcdnotify/btcd.go +++ b/chainntnfs/btcdnotify/btcd.go @@ -180,7 +180,7 @@ func (b *BtcdNotifier) Stop() error { // Shutdown the rpc client, this gracefully disconnects from btcd, and // cleans up all related resources. - b.chainConn.Shutdown() + b.chainConn.Stop() close(b.quit) b.wg.Wait() diff --git a/channeldb/peers.go b/channeldb/peers.go index 62342fc79..ed36c51df 100644 --- a/channeldb/peers.go +++ b/channeldb/peers.go @@ -50,6 +50,12 @@ type FlapCount struct { // bucket for the peer's pubkey if necessary. Note that this function overwrites // the current value. func (d *DB) WriteFlapCounts(flapCounts map[route.Vertex]*FlapCount) error { + // Exit early if there are no updates. + if len(flapCounts) == 0 { + log.Debugf("No flap counts to write, skipped db update") + return nil + } + return kvdb.Update(d, func(tx kvdb.RwTx) error { // Run through our set of flap counts and record them for // each peer, creating a bucket for the peer pubkey if required. diff --git a/docs/release-notes/release-notes-0.19.0.md b/docs/release-notes/release-notes-0.19.0.md index ab9ec1253..04092157c 100644 --- a/docs/release-notes/release-notes-0.19.0.md +++ b/docs/release-notes/release-notes-0.19.0.md @@ -48,6 +48,9 @@ * [Fixed a bug](https://github.com/lightningnetwork/lnd/pull/9249) found in the mission control store that can block the shutdown process of LND. +* Make sure the RPC clients used to access the chain backend are [properly + shutdown](https://github.com/lightningnetwork/lnd/pull/9261). + # New Features ## Functional Enhancements ## RPC Additions @@ -196,4 +199,5 @@ The underlying functionality between those two options remain the same. * Oliver Gugger * Pins * Viktor Tigerström -* Ziggie \ No newline at end of file +* Ziggie + diff --git a/go.mod b/go.mod index e0bda2c29..586cc3299 100644 --- a/go.mod +++ b/go.mod @@ -11,7 +11,7 @@ require ( github.com/btcsuite/btcd/chaincfg/chainhash v1.1.0 github.com/btcsuite/btclog v0.0.0-20241003133417-09c4e92e319c github.com/btcsuite/btclog/v2 v2.0.0-20241017175713-3428138b75c7 - github.com/btcsuite/btcwallet v0.16.10-0.20240912233857-ffb143c77cc5 + github.com/btcsuite/btcwallet v0.16.10-0.20241113134707-b4ff60753aaa github.com/btcsuite/btcwallet/wallet/txauthor v1.3.5 github.com/btcsuite/btcwallet/wallet/txrules v1.2.2 github.com/btcsuite/btcwallet/walletdb v1.4.4 diff --git a/go.sum b/go.sum index 0cf08569c..b64a5c43d 100644 --- a/go.sum +++ b/go.sum @@ -95,8 +95,8 @@ github.com/btcsuite/btclog v0.0.0-20241003133417-09c4e92e319c/go.mod h1:w7xnGOhw github.com/btcsuite/btclog/v2 v2.0.0-20241017175713-3428138b75c7 h1:3Ct3zN3VCEKVm5nceWBBEKczc+jvTfVyOEG71ob2Yuc= github.com/btcsuite/btclog/v2 v2.0.0-20241017175713-3428138b75c7/go.mod h1:XItGUfVOxotJL8kkuk2Hj3EVow5KCugXl3wWfQ6K0AE= github.com/btcsuite/btcutil v0.0.0-20190425235716-9e5f4b9a998d/go.mod h1:+5NJ2+qvTyV9exUAL/rxXi3DcLg2Ts+ymUAY5y4NvMg= -github.com/btcsuite/btcwallet v0.16.10-0.20240912233857-ffb143c77cc5 h1:zYy233eUBvkF3lq2MUkybEhxhDsrRDSgiToIKN57mtk= -github.com/btcsuite/btcwallet v0.16.10-0.20240912233857-ffb143c77cc5/go.mod h1:1HJXYbjJzgumlnxOC2+ViR1U+gnHWoOn7WeK5OfY1eU= +github.com/btcsuite/btcwallet v0.16.10-0.20241113134707-b4ff60753aaa h1:x7vYpwkPL5zeJEWPPaRunybH9ERRMGWeNf7x/0aU/38= +github.com/btcsuite/btcwallet v0.16.10-0.20241113134707-b4ff60753aaa/go.mod h1:1HJXYbjJzgumlnxOC2+ViR1U+gnHWoOn7WeK5OfY1eU= github.com/btcsuite/btcwallet/wallet/txauthor v1.3.5 h1:Rr0njWI3r341nhSPesKQ2JF+ugDSzdPoeckS75SeDZk= github.com/btcsuite/btcwallet/wallet/txauthor v1.3.5/go.mod h1:+tXJ3Ym0nlQc/iHSwW1qzjmPs3ev+UVWMbGgfV1OZqU= github.com/btcsuite/btcwallet/wallet/txrules v1.2.2 h1:YEO+Lx1ZJJAtdRrjuhXjWrYsmAk26wLTlNzxt2q0lhk= diff --git a/lnwallet/chainfee/estimator.go b/lnwallet/chainfee/estimator.go index 6f59c3f7f..f83cce285 100644 --- a/lnwallet/chainfee/estimator.go +++ b/lnwallet/chainfee/estimator.go @@ -238,6 +238,7 @@ func (b *BtcdEstimator) Stop() error { b.filterManager.Stop() b.btcdConn.Shutdown() + b.btcdConn.WaitForShutdown() return nil } diff --git a/routing/chainview/bitcoind.go b/routing/chainview/bitcoind.go index 56e30c24a..cbddb37c1 100644 --- a/routing/chainview/bitcoind.go +++ b/routing/chainview/bitcoind.go @@ -136,6 +136,7 @@ func (b *BitcoindFilteredChainView) Stop() error { // Shutdown the rpc client, this gracefully disconnects from bitcoind's // zmq socket, and cleans up all related resources. b.chainClient.Stop() + b.chainClient.WaitForShutdown() b.blockQueue.Stop() diff --git a/routing/chainview/btcd.go b/routing/chainview/btcd.go index 54c2ee4db..cf08abafe 100644 --- a/routing/chainview/btcd.go +++ b/routing/chainview/btcd.go @@ -146,6 +146,7 @@ func (b *BtcdFilteredChainView) Stop() error { // Shutdown the rpc client, this gracefully disconnects from btcd, and // cleans up all related resources. b.btcdConn.Shutdown() + b.btcdConn.WaitForShutdown() b.blockQueue.Stop()