mirror of
https://github.com/lightningnetwork/lnd.git
synced 2026-08-18 13:07:58 +02:00
waitForWalletSync used time.Tick inside the poll loop, leaking a new goroutine on every iteration. Over 5 reorg cycles with ~300 polls each this accumulated up to 1500 leaked goroutines, adding measurable system load that made the 30s timeout too tight, especially when running against a postgres backend where block-processing writes carry more overhead. Fix the leak by using a single time.NewTicker (deferred Stop), and raise the timeout to 2 minutes to give the neutrino P2P layer and the address-manager transaction walk enough headroom under load. Also improve the timeout error messages to identify which of the two sync layers was stuck: - Layer 1 (header/P2P): ChainIO.GetBestBlock height has not yet caught up to the miner tip — neutrino is still fetching headers. - Layer 2 (transaction walk): heights matched but IsSynced() never returned true — the chain-sync notification or the address-manager DB write (undo+redo on reorg) did not complete in time. Add a detailed doc comment to waitForWalletSync explaining the three pipeline stages (header sync, compact-filter/block fetch, transaction walk) and why each stage is relevant, so a future timeout can be diagnosed from the error message alone. |
||
|---|---|---|
| .. | ||
| bitcoind | ||
| btcd | ||
| neutrino | ||
| test_interface.go | ||