Skip to content

Commit 0876173

Browse files
authored
Merge pull request #9261 from yyforyongyu/fix-rpcclient-shutdown
multi: fix rpcclient shutdown
2 parents 60caa04 + 1c6d894 commit 0876173

File tree

9 files changed

+19
-5
lines changed

9 files changed

+19
-5
lines changed

chainntnfs/bitcoindnotify/bitcoind.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,7 @@ func (b *BitcoindNotifier) Stop() error {
139139
// Shutdown the rpc client, this gracefully disconnects from bitcoind,
140140
// and cleans up all related resources.
141141
b.chainConn.Stop()
142+
b.chainConn.WaitForShutdown()
142143

143144
close(b.quit)
144145
b.wg.Wait()

chainntnfs/btcdnotify/btcd.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ func (b *BtcdNotifier) Stop() error {
180180

181181
// Shutdown the rpc client, this gracefully disconnects from btcd, and
182182
// cleans up all related resources.
183-
b.chainConn.Shutdown()
183+
b.chainConn.Stop()
184184

185185
close(b.quit)
186186
b.wg.Wait()

channeldb/peers.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,12 @@ type FlapCount struct {
5050
// bucket for the peer's pubkey if necessary. Note that this function overwrites
5151
// the current value.
5252
func (d *DB) WriteFlapCounts(flapCounts map[route.Vertex]*FlapCount) error {
53+
// Exit early if there are no updates.
54+
if len(flapCounts) == 0 {
55+
log.Debugf("No flap counts to write, skipped db update")
56+
return nil
57+
}
58+
5359
return kvdb.Update(d, func(tx kvdb.RwTx) error {
5460
// Run through our set of flap counts and record them for
5561
// each peer, creating a bucket for the peer pubkey if required.

docs/release-notes/release-notes-0.19.0.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,9 @@
4848
* [Fixed a bug](https://github.com/lightningnetwork/lnd/pull/9249) found in the
4949
mission control store that can block the shutdown process of LND.
5050

51+
* Make sure the RPC clients used to access the chain backend are [properly
52+
shutdown](https://github.com/lightningnetwork/lnd/pull/9261).
53+
5154
# New Features
5255
## Functional Enhancements
5356
## RPC Additions
@@ -196,4 +199,5 @@ The underlying functionality between those two options remain the same.
196199
* Oliver Gugger
197200
* Pins
198201
* Viktor Tigerström
199-
* Ziggie
202+
* Ziggie
203+

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ require (
1111
github.com/btcsuite/btcd/chaincfg/chainhash v1.1.0
1212
github.com/btcsuite/btclog v0.0.0-20241003133417-09c4e92e319c
1313
github.com/btcsuite/btclog/v2 v2.0.0-20241017175713-3428138b75c7
14-
github.com/btcsuite/btcwallet v0.16.10-0.20240912233857-ffb143c77cc5
14+
github.com/btcsuite/btcwallet v0.16.10-0.20241113134707-b4ff60753aaa
1515
github.com/btcsuite/btcwallet/wallet/txauthor v1.3.5
1616
github.com/btcsuite/btcwallet/wallet/txrules v1.2.2
1717
github.com/btcsuite/btcwallet/walletdb v1.4.4

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,8 +95,8 @@ github.com/btcsuite/btclog v0.0.0-20241003133417-09c4e92e319c/go.mod h1:w7xnGOhw
9595
github.com/btcsuite/btclog/v2 v2.0.0-20241017175713-3428138b75c7 h1:3Ct3zN3VCEKVm5nceWBBEKczc+jvTfVyOEG71ob2Yuc=
9696
github.com/btcsuite/btclog/v2 v2.0.0-20241017175713-3428138b75c7/go.mod h1:XItGUfVOxotJL8kkuk2Hj3EVow5KCugXl3wWfQ6K0AE=
9797
github.com/btcsuite/btcutil v0.0.0-20190425235716-9e5f4b9a998d/go.mod h1:+5NJ2+qvTyV9exUAL/rxXi3DcLg2Ts+ymUAY5y4NvMg=
98-
github.com/btcsuite/btcwallet v0.16.10-0.20240912233857-ffb143c77cc5 h1:zYy233eUBvkF3lq2MUkybEhxhDsrRDSgiToIKN57mtk=
99-
github.com/btcsuite/btcwallet v0.16.10-0.20240912233857-ffb143c77cc5/go.mod h1:1HJXYbjJzgumlnxOC2+ViR1U+gnHWoOn7WeK5OfY1eU=
98+
github.com/btcsuite/btcwallet v0.16.10-0.20241113134707-b4ff60753aaa h1:x7vYpwkPL5zeJEWPPaRunybH9ERRMGWeNf7x/0aU/38=
99+
github.com/btcsuite/btcwallet v0.16.10-0.20241113134707-b4ff60753aaa/go.mod h1:1HJXYbjJzgumlnxOC2+ViR1U+gnHWoOn7WeK5OfY1eU=
100100
github.com/btcsuite/btcwallet/wallet/txauthor v1.3.5 h1:Rr0njWI3r341nhSPesKQ2JF+ugDSzdPoeckS75SeDZk=
101101
github.com/btcsuite/btcwallet/wallet/txauthor v1.3.5/go.mod h1:+tXJ3Ym0nlQc/iHSwW1qzjmPs3ev+UVWMbGgfV1OZqU=
102102
github.com/btcsuite/btcwallet/wallet/txrules v1.2.2 h1:YEO+Lx1ZJJAtdRrjuhXjWrYsmAk26wLTlNzxt2q0lhk=

lnwallet/chainfee/estimator.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -238,6 +238,7 @@ func (b *BtcdEstimator) Stop() error {
238238
b.filterManager.Stop()
239239

240240
b.btcdConn.Shutdown()
241+
b.btcdConn.WaitForShutdown()
241242

242243
return nil
243244
}

routing/chainview/bitcoind.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,7 @@ func (b *BitcoindFilteredChainView) Stop() error {
136136
// Shutdown the rpc client, this gracefully disconnects from bitcoind's
137137
// zmq socket, and cleans up all related resources.
138138
b.chainClient.Stop()
139+
b.chainClient.WaitForShutdown()
139140

140141
b.blockQueue.Stop()
141142

routing/chainview/btcd.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,7 @@ func (b *BtcdFilteredChainView) Stop() error {
146146
// Shutdown the rpc client, this gracefully disconnects from btcd, and
147147
// cleans up all related resources.
148148
b.btcdConn.Shutdown()
149+
b.btcdConn.WaitForShutdown()
149150

150151
b.blockQueue.Stop()
151152

0 commit comments

Comments
 (0)