bitcoin: Creating too many wallets exhausts file descriptor limit and leads to crash
Is there an existing issue for this?
- I have searched the existing issues
Current behaviour
This behavior was first noted by @EthanHeilman here: https://github.com/bitcoin/bitcoin/issues/11368#issuecomment-751574945 but it was conflated with the RPC issue there while I now think this is a separate issue.
When a lot of wallets are created in quick succession, sqlite will exhaust all the available file descriptors and the node crashes the next time it tries to create file for unrelated reasons (blk, rev etc.).
Expected behaviour
The node shouldn’t crash.
Steps to reproduce
for i in $(seq 1 100); do src/bitcoin-cli createwallet "fd-wallet$i"; done
Relevant log output
https://0bin.net/paste/swIJVCaU#CuCCWv7cC4ZscxjCEiauqEhB1icPiMHkYo+D5dC8mSr
How did you obtain Bitcoin Core
Compiled from source
What version of Bitcoin Core are you using?
master
Operating system and version
macOS
Machine specifications
No response
About this issue
- Original URL
- State: open
- Created 3 years ago
- Reactions: 1
- Comments: 17 (17 by maintainers)
Thanks, seems like the relevant short excerpt is:
Feel free to investigate, i am not working on this currently.
I confirm this is still happening on v28 using this script (based on the work of @pinheadmz) to create 300 wallets.
ulimit -n 8192(or higher, doesn’t requiresudo) is a functioning workaround.I’m able to trigger this on macOS with a slightly bigger for loop (the default fd limit for macOS is 256, so anything around that ballpark should trigger). However, looks like this is not making
bitcoindcrash anymore, at least not for me.It’s not how macOS handles it, any OS will cause bitcoind to crash if you use more fd than the limit. It’s just that among all the OS macOS has the lowest standard limit and so such issue are usually observed there first.
Yes. But this doesn’t change that bitcoind can crash and ideally it shouldn’t, which is why I opened this issue.