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 a year ago
- Comments: 15 (15 by maintainers)
Thanks, seems like the relevant short excerpt is:
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
bitcoind
crash 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.
Okay, I was able to reproduce it when lowering the file descriptors and will look further into it. Interesting enough, in my case it doesn’t crash the node but the file descriptors seem to be locked, and can’t load the already created wallets.
I don’t really have any more specifics to give. This was the latest master at the time, compiled only with standard flags and no other wallets present etc. I reproduced the issue 4-5 times consistently with script given above. What OS are you on? If you are not on macOS maybe you have to lower the limit of allowed file descriptors.
Feel free to investigate, i am not working on this currently.