[bug]: wallet stops syncing for good after a block arrives during a short postgres outage
Maintainer thường phản hồi trong vòng 1 ngày
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 4/5
- Thời gian dự kiến
- 1-2 ngày
- Mức phù hợp với người mới
- 55/100
Hướng nghiên cứu
Start with btcwallet's waddrmgr/db.go at PutSyncedTo and wallet/chainntfns.go at handleChainNotifications, then compare the notification path with syncWithChain at startup. Reproduce the reported PostgreSQL outage on regtest and trace how the wallet handles the missed height after the database returns. Done means syncing recovers without restarting lnd and synced_to_chain returns to true.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Pre-Submission Checklist
- I have searched the existing issues and believe this is a new bug.
- I am not asking a question about how to use lnd, but reporting a bug (otherwise open a discussion).
LND Version
Reproduced on:
- master at
0cc5feb(0.21.99-beta, btcwalletv0.18.1) v0.21.8-beta(production incident below)v0.19.2-beta(via lightning-terminalv0.15.1-alpha)
LND Configuration
--bitcoin.regtest --bitcoin.node=bitcoind
--db.backend=postgres
--db.postgres.dsn=postgres://lnd:[email protected]:55432/lnd?sslmode=disable
--db.postgres.timeout=0
--noseedbackup --nolisten
Built with -tags "signrpc walletrpc chainrpc invoicesrpc kvdb_postgres".
Backend Version
bitcoind 29.0.0
Backend Configuration
bitcoind with RPC and ZMQ (zmqpubrawblock, zmqpubrawtx), regtest.
OS/Distribution
macOS 27.2 arm64 for the reproduction; Linux on Kubernetes for the incident.
Bug Details & Steps to Reproduce
If a block is connected while the postgres backend is unreachable, the wallet fails to store that block and never stores another one. lnd keeps running, but synced_to_chain stays false until lnd is restarted.
In one of our signet environments a 27 minute postgres restart left a node unsynced for 5.4 days. Every block after the outage logged:
[ERR] BTWL: Unable to process chain backend block connected notification: failed to store sync information <hash>: failed to fetch block hash for height <n-1>: block not found
Reproduction on regtest:
- Start lnd with
--db.backend=postgresand mine a block.getinfoshowssynced_to_chain: true. - Stop postgres.
- Mine one block. lnd logs:
[ERR] BTWL: Unable to process chain backend block connected notification: failed to connect to `user=lnd database=lnd`: ... connection refused - Start postgres again.
synced_to_chainis nowfalse. - Mine more blocks. Each one logs
failed to store sync information ...: failed to fetch block hash for height <previous>: block not found, andsynced_to_chainstaysfalse. - Restart lnd. The wallet rescans from the last stored block, catches up and reports
synced_to_chain: true. New blocks are stored normally again.
Run on master 0cc5feb:
| Step | Height | synced_to_chain |
store errors |
|---|---|---|---|
| baseline | 341 | true | 0 |
| block during outage | 342 | ||
| postgres back | 342 | false | 0 |
| one more block | 343 | false | 1 |
| two more blocks | 345 | false | 3 |
| after restart | 345 | true | |
| one more block | 346 | true | 0 |
Where it happens (btcwallet v0.18.1):
waddrmgr/db.go:2208PutSyncedTo: once the birthday block is set, it requires the hash ofheight-1to be stored and returnsErrBlockNotFoundotherwise.wallet/chainntfns.go:165-183handleChainNotifications: the error is only logged. TheErrBlockNotFoundcase is skipped with a comment that the wallet will catch up when the rescan finishes, but only while!w.ChainSynced(). Here the wallet was synced, so no rescan is running and nothing fills the gap. The catch up only happens insyncWithChainat startup, which is why a restart fixes it.
Expected Behavior
After the database is back, the wallet should store the missed block (for example by retrying it, or by catching up from its last stored height, as syncWithChain does at startup) and continue syncing without a restart.
Debug Information
Full log of the master run available on request.
Environment
Related: an etcd outage of a few minutes crashes lnd with a nil pointer dereference in the same handler. Filed separately: #11640.
- Ngôn ngữ chính
- Go
- Star
- 8.2k
- Fork
- 2.3k
- Merge trung bình
- 1 ngày 11 giờ
- Pull request đã merge (30 ngày)
- 103
Chuẩn bị môi trường
- Có Dockerfile hoặc tệp Docker Compose
- Có mẫu pull request
- Không có hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của lightningnetwork/lnd
-
funding: failure logs print `<nil>` error and zero channel IDCó thể đã có người làm @litbot-9000 đã nhận hôm nay. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 90/100
lightningnetwork/lnd#11676 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 Nửa ngày Mức phù hợp với người mới 85/100
lightningnetwork/lnd#11674 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
lightningnetwork/lnd#11672 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
test flake
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
lightningnetwork/lnd#11663 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
[flake]: lnwallet/test/bitcoind.TestLightningWalletBitcoindRPCPolling/spend_unconfirmed_outputsĐang mởtest flake
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
lightningnetwork/lnd#11642 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của lightningnetwork/lnd
Issue tương tự
-
ConcatAgenticMessages loses the approval request ID of a streamed MCP tool callCó thể đã có người làm @ningsiyuan1024 đã nhận hôm nay. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 86/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 74/100
containers/gvisor-tap-vsock#796 ·
Maintainer thường phản hồi trong vòng 2 ngày
-
external needs:triage
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
celestiaorg/celestia-node#5448 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 79/100
Maintainer thường phản hồi trong vòng 1 ngày
-
[Bug]: Azure SAS signing uses local time instead of UTC, shifting validity window on non-UTC hostsCó thể đã có người làm @huanghaoyuanhhy đã nhận hôm nay. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
zilliztech/milvus-backup#1418 ·
Maintainer thường phản hồi trong vòng 1 ngày