electrs icon indicating copy to clipboard operation
electrs copied to clipboard

Bug: Failure when bitcoind has not yet loaded mempool

Open haarp opened this issue 1 year ago • 1 comments

Describe the bug Hello!

bitcoind can take a LONG time to load the mempool after a start. This can take several hours (especially on HDDs it seems) (corroborated here). This is evident by Progress loading mempool transactions from disk: 10% messages (after bitcoin/bitcoin#29227).

In this state, bitcoind will answer getmempoolinfo with loaded: false.

electrs is close to unusable in this state and log things like mempool sync failed: batch getmempoolentry/getrawtransaction request failed: transport error: Couldn't connect to host: Resource temporarily unavailable (os error 11). Clients will be unable to connect, and fail in very mysterious ways (unless Electrum's verbose logs are enabled and closely looked at)

electrs will eventually give up/time out and quit. If however mempool becomes available before electrs quits, it'll keep running but complain about a LOT of missing mempool entry that it couldn't load up to this point.

Electrs version git as of 74b868c6e

To Reproduce Steps to reproduce the behavior:

  1. Restart bitcoind and electrs shortly after
  2. Try to connect with clients
  3. Wait
  4. See error

Expected behavior If it's not possible to gracefully work around the lack of mempool (e.g. by checking getmempoolinfo and not trying if it's unavailable yet), electrs should refuse to start until the mempool is loaded. Kind of how it also refuses to start until IBD is done. This would prevent many of the weird problems related to this.

Configuration Nothing special

Electrum client Electrum 4.5.4

Thanks!

haarp avatar May 22 '24 02:05 haarp

Good idea - thanks for reporting the issue and suggesting a solution :)

romanz avatar May 24 '24 11:05 romanz

Should be resolved by https://github.com/romanz/electrs/pull/1091.

romanz avatar Nov 24 '24 17:11 romanz