Skip to content

Improve reliability of wait_and_check_bitcoind#9240

Open
NicolasDorier wants to merge 3 commits into
ElementsProject:masterfrom
btcpayserver:reliable-rpcwait
Open

Improve reliability of wait_and_check_bitcoind#9240
NicolasDorier wants to merge 3 commits into
ElementsProject:masterfrom
btcpayserver:reliable-rpcwait

Conversation

@NicolasDorier

@NicolasDorier NicolasDorier commented Jun 22, 2026

Copy link
Copy Markdown
Contributor

bitcoin-cli -rpcwait works probably as expected if the blocks are loading before core lightning start. But doesn't if BitcoinD isn't listening at all before Core Lightning wait, we observed the following behavior.

  • Timestamp: 0: Core Lightning Starts and wait RPC
  • Timestamp: 10: Bitcoind starts
  • Timestamp: 30: Core Lightning fails (RPC connection timed out)
  • Timestamp: 31: Core Lightning Container crashes, docker restart it
  • Timestamp: 32: Core Lightning Starts, AND detect bitcoind started

Rather than waiting for 30 seconds, this PR wait 30 times for 1 seconds. This fix the issue for us.

  • Timestamp: 0: Core Lightning Starts and wait RPC
  • Timestamp: 10: Bitcoind starts
  • Timestamp: 11: Core Lightning detect bitcoind started

This is a patch we are using in BTCPay Server deployments. Not really critical in production scenario, but it was causing our tests to fail as lightningd was taking 30 seconds to properly start.

Changelog-Fixed: Fixed spurious bitcoind startup failures by retrying bitcoin-cli -rpcwait checks when RPC briefly fails.
@NicolasDorier NicolasDorier marked this pull request as ready for review June 22, 2026 01:20

@nGoline nGoline left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice fix there. I just have 2 small changes before approving.

Comment thread plugins/bcli.c
Comment thread plugins/bcli.c Outdated
@nGoline nGoline added this to the v26.09 milestone Jun 29, 2026
NicolasDorier and others added 2 commits June 30, 2026 11:42
Co-authored-by: Níckolas Goline <nickolas.goline@gmail.com>
Co-authored-by: Níckolas Goline <nickolas.goline@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants