Creating too many wallets exhausts file descriptor limit and leads to crash #27732

issue fjahr opened this issue on May 23, 2023
  1. fjahr commented at 11:38 PM on May 23, 2023: contributor

    Is there an existing issue for this?

    • I have searched the existing issues

    Current behaviour

    This behavior was first noted by @EthanHeilman here: #11368 (comment) 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

  2. maflcko added the label Wallet on May 24, 2023
  3. dimitaracev commented at 6:53 PM on June 13, 2023: contributor

    I can take this if still available.

  4. fjahr commented at 9:57 PM on June 13, 2023: contributor

    I can take this if still available.

    Feel free to investigate, i am not working on this currently.

  5. dimitaracev commented at 2:09 PM on June 14, 2023: contributor

    Unfortunately I was not able to reproduce this after multiple tests. Do you maybe have a more specific scenario where the issue would occur?

  6. fjahr commented at 2:48 PM on June 14, 2023: contributor

    Unfortunately I was not able to reproduce this after multiple tests. Do you maybe have a more specific scenario where the issue would occur?

    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.

  7. dimitaracev commented at 2:53 PM on June 14, 2023: contributor

    I'm on an ArchLinux installation, and I see that the number of allowed file descriptors is pretty high which is probably why I can't reproduce it. Will lower them and try again, thanks.

  8. maflcko commented at 3:28 PM on June 14, 2023: member

    Relevant log output ... 0bin

    If you upload logs, it could help to either put them in the comment (maybe via <details><summary></summary></details>) or by uploading it to the same site that hosts the comment. Otherwise the external site is just another thing that can go down or is unreachable, which is the case here for me at least.

  9. fjahr commented at 3:33 PM on June 14, 2023: contributor

    If you upload logs, it could help to either put them in the comment (maybe via <details><summary></summary></details>) or by uploading it to the same site that hosts the comment. Otherwise the external site is just another thing that can go down or is unreachable, which is the case here for me at least.

    GitHub didn't allow me to paste the logs in a comment because they were too big...

  10. fjahr commented at 3:34 PM on June 14, 2023: contributor

    Trying with attached file... wallet_exhaust.txt

  11. fjahr commented at 3:35 PM on June 14, 2023: contributor

    Ok, seems to have worked. But when I created the issue it failed.

  12. maflcko commented at 3:37 PM on June 14, 2023: member

    Thanks, seems like the relevant short excerpt is:

    2023-05-23T22:32:53Z SQLite Error. Code: 14. Message: os_unix.c:46922: (24) open(/Users/FJ/Library/Application Support/Bitcoin/testnet3/wallets/fd-wallet99/wallet.dat-journal) - Too many open files
    2023-05-23T22:32:53Z SQLite Error. Code: 14. Message: statement aborts at 1: [BEGIN EXCLUSIVE TRANSACTION] unable to open database file
    2023-05-23T22:32:53Z Using SQLite Version 3.39.5
    2023-05-23T22:32:53Z Using wallet /Users/FJ/Library/Application Support/Bitcoin/testnet3/wallets/fd-wallet100
    2023-05-23T22:32:53Z SQLite Error. Code: 14. Message: cannot open file at line 46922 of [554764a6e7]
    2023-05-23T22:32:53Z SQLite Error. Code: 14. Message: os_unix.c:46922: (24) open(/Users/FJ/Library/Application Support/Bitcoin/testnet3/wallets/fd-wallet100/wallet.dat-journal) - Too many open files
    2023-05-23T22:32:53Z SQLite Error. Code: 14. Message: statement aborts at 1: [BEGIN EXCLUSIVE TRANSACTION] unable to open database file
    2023-05-23T22:33:38Z UpdateTip: new best=00000000607ba1efbd078e5a305b832ae14a6c444b5aa9b557db4982cca74aed height=1148054 version=0x20000000 log2_work=69.251056 tx=14198802 date='2017-06-24T09:42:34Z' progress=0.216198 cache=45.4MiB(394627txo)
    2023-05-23T22:33:38Z UpdateTip: new best=00000000b7e5ec444dfcf9cff739783eb0550c692ff1c66cfe37af6374fbaad6 height=1148055 version=0x20000000 log2_work=69.251056 tx=14199082 date='2017-06-24T10:02:36Z' progress=0.216202 cache=50.5MiB(414075txo)
    2023-05-23T22:33:39Z UpdateTip: new best=0000000013869d488791f4961dcf1b1f93f050b0a787616359b6355a70701e86 height=1148056 version=0x20000000 log2_work=69.251056 tx=14199702 date='2017-06-24T10:29:53Z' progress=0.216212 cache=50.8MiB(414298txo)
    2023-05-23T22:33:39Z New outbound peer connected: version: 70015, blocks=2435012, peer=6 (outbound-full-relay)
    2023-05-23T22:33:39Z UpdateTip: new best=0000000086afcb0260af2c4f609535db645a0f765484d389834c0309030eabcb height=1148057 version=0x20000000 log2_work=69.251056 tx=14200140 date='2017-06-24T10:52:00Z' progress=0.216219 cache=50.8MiB(414672txo)
    2023-05-23T22:33:39Z UpdateTip: new best=000000009be200143cc507115d9a57504241f80536b0e9fa0a304fc9f13a7f14 height=1148058 version=0x00000004 log2_work=69.251056 tx=14200141 date='2017-06-24T11:15:47Z' progress=0.216219 cache=50.8MiB(414674txo)
    2023-05-23T22:33:39Z New outbound peer connected: version: 70016, blocks=2435012, peer=5 (outbound-full-relay)
    2023-05-23T22:33:39Z UpdateTip: new best=000000000e0e1b8cc908edb67e8a9329a256b162ab45a8bbfe83a9773fe32bbd height=1148059 version=0x20000000 log2_work=69.251056 tx=14200255 date='2017-06-24T11:39:07Z' progress=0.216220 cache=50.8MiB(414513txo)
    2023-05-23T22:34:26Z UpdateTip: new best=000000003aae175dee028b660af7116bf8fa66ad2934845e961b9839a18821d8 height=1148060 version=0x20000000 log2_work=69.251056 tx=14200492 date='2017-06-24T12:00:07Z' progress=0.216224 cache=50.8MiB(414378txo)
    2023-05-23T22:34:26Z UpdateTip: new best=00000000f7bd2dbd40619d3a20755603f010012af19f5aafbbab46ae374160db height=1148061 version=0x20000000 log2_work=69.251056 tx=14201162 date='2017-06-24T12:20:08Z' progress=0.216234 cache=50.8MiB(414715txo)
    2023-05-23T22:34:26Z UpdateTip: new best=0000000003110e54d36f4113fc94f46a4463e5da18eb356e4cc0d67bb2fa79c5 height=1148062 version=0x20000000 log2_work=69.251056 tx=14201706 date='2017-06-24T12:57:58Z' progress=0.216242 cache=50.8MiB(414666txo)
    2023-05-23T22:34:26Z UpdateTip: new best=000000003b71aa64a460b2f7ebe40a959ed3e9c2fe02af8df4a99fda44efe906 height=1148063 version=0x20000000 log2_work=69.251056 tx=14202041 date='2017-06-24T13:19:45Z' progress=0.216247 cache=50.8MiB(414737txo)
    2023-05-23T22:34:26Z New outbound peer connected: version: 70016, blocks=2435012, peer=7 (outbound-full-relay)
    2023-05-23T22:34:26Z New outbound peer connected: version: 70016, blocks=2435012, peer=8 (outbound-full-relay)
    2023-05-23T22:34:26Z Synchronizing blockheaders, height: 2435012 (~100.00%)
    2023-05-23T22:34:26Z UpdateTip: new best=00000000a41344a056a034e823dd4108d6186f9d61449354c29d617f5222bad3 height=1148064 version=0x20000000 log2_work=69.251056 tx=14202449 date='2017-06-24T13:56:46Z' progress=0.216254 cache=50.8MiB(414869txo)
    2023-05-23T22:34:26Z UpdateTip: new best=00000000823daf27e85da59baa4c6a6b90d98283d45f425c84351592dc7655df height=1148065 version=0x20000000 log2_work=69.251056 tx=14202845 date='2017-06-24T14:20:57Z' progress=0.216260 cache=52.3MiB(428380txo)
    2023-05-23T22:34:51Z Unable to open file /Users/FJ/Library/Application Support/Bitcoin/testnet3/blocks/rev00076.dat
    2023-05-23T22:34:51Z ERROR: UndoWriteToDisk: OpenUndoFile failed
    2023-05-23T22:34:51Z *** Failed to write undo data
    2023-05-23T22:34:51Z Error: A fatal internal error occurred, see debug.log for details
    2023-05-23T22:34:51Z tor: Thread interrupt
    2023-05-23T22:34:51Z addcon thread exit
    2023-05-23T22:34:51Z Shutdown: In progress...
    2023-05-23T22:34:51Z opencon thread exit
    2023-05-23T22:34:51Z torcontrol thread exit
    2023-05-23T22:34:51Z ERROR: ConnectTip: ConnectBlock 00000000c101ef80a98b3e6e11d925578c02512f37731838a911591e7e64b858 failed, Failed to write undo data
    2023-05-23T22:34:51Z ERROR: ProcessNewBlock: ActivateBestChain failed (Failed to write undo data)
    2023-05-23T22:34:51Z msghand thread exit
    2023-05-23T22:34:51Z net thread exit
    2023-05-23T22:34:51Z DumpAnchors: Flush 0 outbound block-relay-only peer addresses to anchors.dat started
    2023-05-23T22:34:51Z DumpAnchors: Flush 0 outbound block-relay-only peer addresses to anchors.dat completed (0.00s)
    2023-05-23T22:34:52Z scheduler thread exit
    2023-05-23T22:34:52Z Writing 0 unbroadcast transactions to disk.
    2023-05-23T22:34:52Z Dumped mempool: 4.75e-05s to copy, 0.00576754s to dump
    
  13. dimitaracev commented at 7:15 PM on June 14, 2023: contributor

    Unfortunately I was not able to reproduce this after multiple tests. Do you maybe have a more specific scenario where the issue would occur?

    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.

    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.

    2023-06-14T19:22:21Z [fd-wallet1] Releasing wallet
    2023-06-14T19:22:22Z Using SQLite Version 3.40.1
    2023-06-14T19:22:22Z Using wallet /home/dimitaracev/.bitcoin/regtest/wallets/fd-wallet1
    2023-06-14T19:22:22Z init message: Loading wallet…
    2023-06-14T19:22:22Z [fd-wallet1] Wallet file version = 10500, last client version = 259900
    2023-06-14T19:22:22Z [fd-wallet1] Setting spkMan to active: id = 5e306353541637e7a8a5544e5b257ba8f1d3c488f2e9fd7cbf8b050742e3ec8d, type = legacy, internal = false
    2023-06-14T19:22:22Z [fd-wallet1] Setting spkMan to active: id = 46059f1ecfbe2666420840110eb03da53c829a2a1296bb63c64d5daf562d070b, type = p2sh-segwit, internal = false
    2023-06-14T19:22:22Z [fd-wallet1] Setting spkMan to active: id = e60db0e290b20b41cccd1c62b47120159af0e747b5829eb611118c6f053df157, type = bech32, internal = false
    2023-06-14T19:22:22Z [fd-wallet1] Setting spkMan to active: id = f706629e5c33dfe527c2f5ec6e2c0f0d36f3cc75f6e56b711554198e9120d2ca, type = bech32m, internal = false
    2023-06-14T19:22:22Z [fd-wallet1] Setting spkMan to active: id = 6c17557bdb8f060982bd9478d20c33989fec840f5fca6104f5c9b77ae2000425, type = legacy, internal = true
    2023-06-14T19:22:22Z [fd-wallet1] Setting spkMan to active: id = 6120ab62678492d7f653409175de0ac0bfbab67f7501b2387533477c8a14ee17, type = p2sh-segwit, internal = true
    2023-06-14T19:22:22Z [fd-wallet1] Setting spkMan to active: id = c9bb633eaf2982beb1711e977e8e679374160a898cf392a886f81ac41829c5e7, type = bech32, internal = true
    2023-06-14T19:22:22Z [fd-wallet1] Setting spkMan to active: id = 15400e0ed8a94b5e6b245b991e78dc2f467873cea42ee508d4a3563bdb6456f1, type = bech32m, internal = true
    2023-06-14T19:22:22Z [fd-wallet1] Keys: 8 plaintext, 0 encrypted, 0 w/ metadata, 8 total. Unknown wallet records: 0
    2023-06-14T19:22:22Z SQLite Error. Code: 14. Message: cannot open file at line 42907 of [df5c253c0b]
    2023-06-14T19:22:22Z SQLite Error. Code: 14. Message: os_unix.c:42907: (24) open(/home/dimitaracev/.bitcoin/regtest/wallets/fd-wallet1/wallet.dat-journal) - 
    2023-06-14T19:22:22Z SQLite Error. Code: 14. Message: statement aborts at 14: [INSERT or REPLACE into main values(?, ?)] unable to open database file
    2023-06-14T19:22:22Z WriteKey: Unable to execute statement: unable to open database file
    2023-06-14T19:22:22Z [fd-wallet1] Releasing wallet
    2023-06-14T19:27:36Z CreateNewBlock(): block weight: 892 txs: 0 fees: 0 sigops 400
    2023-06-14T19:27:36Z Saw new header hash=1786ef9d4d7625c83d48e6e706c2d2cd53cb73f2023ad369aa9200a5269bf87f height=405
    2023-06-14T19:27:36Z UpdateTip: new best=1786ef9d4d7625c83d48e6e706c2d2cd53cb73f2023ad369aa9200a5269bf87f height=405 version=0x30000000 log2_work=9.665336 tx=406 date='2023-06-14T19:27:36Z' progress=1.000000 cache=0.3MiB(304txo)
    
  14. dimitaracev commented at 8:10 PM on June 14, 2023: contributor

    After a deeper look, I think the crashing may be related to how macOS handles file descriptors when you try to use more than the limit. Bitcoin Core loads the wallet immediately after you create it and it keeps that file descriptor open for easy access. You can try running bitcoin-cli listwallets and you should see all of the wallets created up until the point where you go over the file descriptor limit.

  15. fjahr commented at 11:41 AM on June 18, 2023: contributor

    After a deeper look, I think the crashing may be related to how macOS handles file descriptors when you try to use more than the limit.

    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.

    Bitcoin Core loads the wallet immediately after you create it and it keeps that file descriptor open for easy access. You can try running bitcoin-cli listwallets and you should see all of the wallets created up until the point where you go over the file descriptor limit.

    Yes. But this doesn't change that bitcoind can crash and ideally it shouldn't, which is why I opened this issue.

  16. bitcoin deleted a comment on Jun 18, 2023
  17. maflcko added the label macOS on Jun 21, 2023
  18. sr-gi commented at 2:43 PM on June 22, 2023: member

    After a deeper look, I think the crashing may be related to how macOS handles file descriptors when you try to use more than the limit.

    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.

    Bitcoin Core loads the wallet immediately after you create it and it keeps that file descriptor open for easy access. You can try running bitcoin-cli listwallets and you should see all of the wallets created up until the point where you go over the file descriptor limit.

    Yes. But this doesn't change that bitcoind can crash and ideally it shouldn't, which is why I opened this issue.

    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.

    [...]
    2023-06-22T14:38:41Z [rpc] ThreadRPCServer method=createwallet user=user
    2023-06-22T14:38:41Z Using SQLite Version 3.39.5
    2023-06-22T14:38:41Z Using wallet /Users/sergi/Library/Application Support/Bitcoin/regtest/wallets/fd-wallet132
    2023-06-22T14:38:41Z SQLite Error. Code: 14. Message: cannot open file at line 46922 of [554764a6e7]
    2023-06-22T14:38:41Z SQLite Error. Code: 14. Message: os_unix.c:46922: (24) open(/Users/sergi/.bitcoin/regtest/wallets/fd-wallet132/wallet.dat-journal) - Too many open files
    2023-06-22T14:38:41Z SQLite Error. Code: 14. Message: statement aborts at 1: [BEGIN EXCLUSIVE TRANSACTION] unable to open database file
    2023-06-22T14:38:41Z [http] Received a POST request for / from 127.0.0.1:49976
    2023-06-22T14:38:41Z [rpc] ThreadRPCServer method=createwallet user=user
    2023-06-22T14:38:41Z Using SQLite Version 3.39.5
    2023-06-22T14:38:41Z Using wallet /Users/sergi/Library/Application Support/Bitcoin/regtest/wallets/fd-wallet133
    2023-06-22T14:38:41Z SQLite Error. Code: 14. Message: cannot open file at line 46922 of [554764a6e7]
    2023-06-22T14:38:41Z SQLite Error. Code: 14. Message: os_unix.c:46922: (24) open(/Users/sergi/.bitcoin/regtest/wallets/fd-wallet133/wallet.dat-journal) - Too many open files
    2023-06-22T14:38:41Z SQLite Error. Code: 14. Message: statement aborts at 1: [BEGIN EXCLUSIVE TRANSACTION] unable to open database file
    2023-06-22T14:38:41Z [http] Received a POST request for / from 127.0.0.1:49977
    [...]
    
  19. willcl-ark commented at 11:09 AM on September 15, 2023: member

    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.

    I found similar behaviour on master@ f608a409f7591b4f5cf170898bee58b9d9dcf1b6 My system encountered errors after adding only 131 wallets, but did not crash and was able to shutdown cleanly too:

    <details> <summary>Details</summary>

    
    <snip>
    
    2023-09-15T11:02:35Z Using wallet /Users/will/Library/Application Support/Bitcoin/regtest/wallets/fd-wallet131
    2023-09-15T11:02:35Z SQLite Error. Code: 14. Message: cannot open file at line 42184 of [554764a6e7]
    2023-09-15T11:02:35Z SQLite Error. Code: 14. Message: os_unix.c:42184: (24) openDirectory(/Users/will/Library/Application Support/Bitcoin/regtest/wallets/fd-wallet131) - Too many open files
    2023-09-15T11:02:36Z init message: Loading wallet…
    2023-09-15T11:02:36Z [fd-wallet131] Wallet file version = 10500, last client version = 259900
    2023-09-15T11:02:36Z [fd-wallet131] Legacy Wallet Keys: 0 plaintext, 0 encrypted, 0 w/ metadata, 0 total.
    2023-09-15T11:02:36Z [fd-wallet131] Descriptors: 0, Descriptor Keys: 0 plaintext, 0 encrypted, 0 total.
    2023-09-15T11:02:36Z [fd-wallet131] Setting minversion to 169900
    2023-09-15T11:02:36Z [fd-wallet131] Setting spkMan to active: id = 5113ed2b9223576f1d1c3fe357d6ebe2af35519f034f609fb4c4369d2960dbab, type = legacy, internal = false
    2023-09-15T11:02:36Z [fd-wallet131] Setting spkMan to active: id = 61b14d4f338e78d4a290e717ed231adcade3b905e4850ff9350ba86c7540a940, type = p2sh-segwit, internal = false
    2023-09-15T11:02:37Z [fd-wallet131] Setting spkMan to active: id = 2c567a4fc58bbe1d167a615d6b0fbef0b3e53bef086c4b82af4bdff6d0f2a971, type = bech32, internal = false
    2023-09-15T11:02:37Z [fd-wallet131] Setting spkMan to active: id = 5907eac043ec550b3956bc2cd7be24d29e19f1e7a1ec4916808e25a64190dd5c, type = bech32m, internal = false
    2023-09-15T11:02:37Z [fd-wallet131] Setting spkMan to active: id = 2b7830bb39af4881c58d7d541112651266613283244c7e0452f96336b286c309, type = legacy, internal = true
    2023-09-15T11:02:37Z [fd-wallet131] Setting spkMan to active: id = 9c10d5b227a5f5c69638cda034ab663636cdca420d536952243fdfbfadb4a242, type = p2sh-segwit, internal = true
    2023-09-15T11:02:38Z [fd-wallet131] Setting spkMan to active: id = 92a633ac0a53837f27c3c579a45c4ee2b7ec2395fea19967f0341c301325e9c6, type = bech32, internal = true
    2023-09-15T11:02:38Z [fd-wallet131] Setting spkMan to active: id = 008c71a0d87a54001383a03f4e64188020f512150a25c7826ccf82d03c084b78, type = bech32m, internal = true
    2023-09-15T11:02:38Z [fd-wallet131] Wallet completed loading in            2619ms
    2023-09-15T11:02:38Z [fd-wallet131] setKeyPool.size() = 8000
    2023-09-15T11:02:38Z [fd-wallet131] mapWallet.size() = 0
    2023-09-15T11:02:38Z [fd-wallet131] m_address_book.size() = 0
    2023-09-15T11:02:38Z Using SQLite Version 3.39.5
    2023-09-15T11:02:38Z Using wallet /Users/will/Library/Application Support/Bitcoin/regtest/wallets/fd-wallet132
    2023-09-15T11:02:38Z SQLite Error. Code: 14. Message: cannot open file at line 46922 of [554764a6e7]
    2023-09-15T11:02:38Z SQLite Error. Code: 14. Message: os_unix.c:46922: (24) open(/Users/will/Library/Application Support/Bitcoin/regtest/wallets/fd-wallet132/wallet.dat) - Too many open files
    2023-09-15T11:02:38Z Using SQLite Version 3.39.5
    2023-09-15T11:02:38Z Using wallet /Users/will/Library/Application Support/Bitcoin/regtest/wallets/fd-wallet133
    2023-09-15T11:02:38Z SQLite Error. Code: 14. Message: cannot open file at line 46922 of [554764a6e7]
    2023-09-15T11:02:38Z SQLite Error. Code: 14. Message: os_unix.c:46922: (24) open(/Users/will/Library/Application Support/Bitcoin/regtest/wallets/fd-wallet133/wallet.dat) - Too many open files
    
    <snip>
    
    ^C2023-09-15T11:02:48Z tor: Thread interrupt
    2023-09-15T11:02:48Z opencon thread exit
    2023-09-15T11:02:48Z addcon thread exit
    2023-09-15T11:02:48Z torcontrol thread exit
    2023-09-15T11:02:48Z Shutdown: In progress...
    2023-09-15T11:02:48Z net thread exit
    2023-09-15T11:02:48Z msghand thread exit
    2023-09-15T11:02:48Z DumpAnchors: Flush 0 outbound block-relay-only peer addresses to anchors.dat started
    2023-09-15T11:02:48Z DumpAnchors: Flush 0 outbound block-relay-only peer addresses to anchors.dat completed (0.00s)
    2023-09-15T11:02:48Z scheduler thread exit
    2023-09-15T11:02:48Z Writing 0 unbroadcast transactions to disk.
    2023-09-15T11:02:48Z Dumped mempool: 0.00206033s to copy, 0.00876938s to dump
    2023-09-15T11:02:48Z Flushed fee estimates to fee_estimates.dat.
    2023-09-15T11:02:55Z [fd-wallet131] Releasing wallet
    2023-09-15T11:02:55Z [fd-wallet130] Releasing wallet
    2023-09-15T11:02:55Z [fd-wallet129] Releasing wallet
    2023-09-15T11:02:55Z [fd-wallet128] Releasing wallet
    2023-09-15T11:02:55Z [fd-wallet127] Releasing wallet
    2023-09-15T11:02:55Z [fd-wallet126] Releasing wallet
    2023-09-15T11:02:55Z [fd-wallet125] Releasing wallet
    2023-09-15T11:02:55Z [fd-wallet124] Releasing wallet
    2023-09-15T11:02:55Z [fd-wallet123] Releasing wallet
    2023-09-15T11:02:55Z [fd-wallet122] Releasing wallet
    2023-09-15T11:02:55Z [fd-wallet121] Releasing wallet
    2023-09-15T11:02:55Z [fd-wallet120] Releasing wallet
    2023-09-15T11:02:55Z [fd-wallet119] Releasing wallet
    2023-09-15T11:02:55Z [fd-wallet118] Releasing wallet
    2023-09-15T11:02:55Z [fd-wallet117] Releasing wallet
    2023-09-15T11:02:55Z [fd-wallet116] Releasing wallet
    2023-09-15T11:02:55Z [fd-wallet115] Releasing wallet
    2023-09-15T11:02:55Z [fd-wallet114] Releasing wallet
    2023-09-15T11:02:55Z [fd-wallet113] Releasing wallet
    2023-09-15T11:02:55Z [fd-wallet112] Releasing wallet
    2023-09-15T11:02:55Z [fd-wallet111] Releasing wallet
    2023-09-15T11:02:55Z [fd-wallet110] Releasing wallet
    2023-09-15T11:02:55Z [fd-wallet109] Releasing wallet
    2023-09-15T11:02:55Z [fd-wallet108] Releasing wallet
    2023-09-15T11:02:55Z [fd-wallet107] Releasing wallet
    2023-09-15T11:02:55Z [fd-wallet106] Releasing wallet
    2023-09-15T11:02:55Z [fd-wallet105] Releasing wallet
    2023-09-15T11:02:55Z [fd-wallet104] Releasing wallet
    2023-09-15T11:02:55Z [fd-wallet103] Releasing wallet
    2023-09-15T11:02:55Z [fd-wallet102] Releasing wallet
    2023-09-15T11:02:55Z [fd-wallet101] Releasing wallet
    2023-09-15T11:02:55Z [fd-wallet100] Releasing wallet
    2023-09-15T11:02:55Z [fd-wallet99] Releasing wallet
    2023-09-15T11:02:55Z [fd-wallet98] Releasing wallet
    2023-09-15T11:02:55Z [fd-wallet97] Releasing wallet
    2023-09-15T11:02:55Z [fd-wallet96] Releasing wallet
    2023-09-15T11:02:55Z [fd-wallet95] Releasing wallet
    2023-09-15T11:02:55Z [fd-wallet94] Releasing wallet
    2023-09-15T11:02:55Z [fd-wallet93] Releasing wallet
    2023-09-15T11:02:55Z [fd-wallet92] Releasing wallet
    2023-09-15T11:02:55Z [fd-wallet91] Releasing wallet
    2023-09-15T11:02:55Z [fd-wallet90] Releasing wallet
    2023-09-15T11:02:55Z [fd-wallet89] Releasing wallet
    2023-09-15T11:02:55Z [fd-wallet88] Releasing wallet
    2023-09-15T11:02:55Z [fd-wallet87] Releasing wallet
    2023-09-15T11:02:55Z [fd-wallet86] Releasing wallet
    2023-09-15T11:02:56Z [fd-wallet85] Releasing wallet
    2023-09-15T11:02:56Z [fd-wallet84] Releasing wallet
    2023-09-15T11:02:56Z [fd-wallet83] Releasing wallet
    2023-09-15T11:02:56Z [fd-wallet82] Releasing wallet
    2023-09-15T11:02:56Z [fd-wallet81] Releasing wallet
    2023-09-15T11:02:56Z [fd-wallet80] Releasing wallet
    2023-09-15T11:02:56Z [fd-wallet79] Releasing wallet
    2023-09-15T11:02:56Z [fd-wallet78] Releasing wallet
    2023-09-15T11:02:56Z [fd-wallet77] Releasing wallet
    2023-09-15T11:02:56Z [fd-wallet76] Releasing wallet
    2023-09-15T11:02:56Z [fd-wallet75] Releasing wallet
    2023-09-15T11:02:56Z [fd-wallet74] Releasing wallet
    2023-09-15T11:02:56Z [fd-wallet73] Releasing wallet
    2023-09-15T11:02:56Z [fd-wallet72] Releasing wallet
    2023-09-15T11:02:56Z [fd-wallet71] Releasing wallet
    2023-09-15T11:02:56Z [fd-wallet70] Releasing wallet
    2023-09-15T11:02:56Z [fd-wallet69] Releasing wallet
    2023-09-15T11:02:56Z [fd-wallet68] Releasing wallet
    2023-09-15T11:02:56Z [fd-wallet67] Releasing wallet
    2023-09-15T11:02:56Z [fd-wallet66] Releasing wallet
    2023-09-15T11:02:56Z [fd-wallet65] Releasing wallet
    2023-09-15T11:02:56Z [fd-wallet64] Releasing wallet
    2023-09-15T11:02:56Z [fd-wallet63] Releasing wallet
    2023-09-15T11:02:56Z [fd-wallet62] Releasing wallet
    2023-09-15T11:02:56Z [fd-wallet61] Releasing wallet
    2023-09-15T11:02:56Z [fd-wallet60] Releasing wallet
    2023-09-15T11:02:56Z [fd-wallet59] Releasing wallet
    2023-09-15T11:02:56Z [fd-wallet58] Releasing wallet
    2023-09-15T11:02:56Z [fd-wallet57] Releasing wallet
    2023-09-15T11:02:56Z [fd-wallet56] Releasing wallet
    2023-09-15T11:02:56Z [fd-wallet55] Releasing wallet
    2023-09-15T11:02:56Z [fd-wallet54] Releasing wallet
    2023-09-15T11:02:56Z [fd-wallet53] Releasing wallet
    2023-09-15T11:02:56Z [fd-wallet52] Releasing wallet
    2023-09-15T11:02:56Z [fd-wallet51] Releasing wallet
    2023-09-15T11:02:56Z [fd-wallet50] Releasing wallet
    2023-09-15T11:02:56Z [fd-wallet49] Releasing wallet
    2023-09-15T11:02:56Z [fd-wallet48] Releasing wallet
    2023-09-15T11:02:56Z [fd-wallet47] Releasing wallet
    2023-09-15T11:02:56Z [fd-wallet46] Releasing wallet
    2023-09-15T11:02:56Z [fd-wallet45] Releasing wallet
    2023-09-15T11:02:56Z [fd-wallet44] Releasing wallet
    2023-09-15T11:02:56Z [fd-wallet43] Releasing wallet
    2023-09-15T11:02:56Z [fd-wallet42] Releasing wallet
    2023-09-15T11:02:56Z [fd-wallet41] Releasing wallet
    2023-09-15T11:02:56Z [fd-wallet40] Releasing wallet
    2023-09-15T11:02:56Z [fd-wallet39] Releasing wallet
    2023-09-15T11:02:56Z [fd-wallet38] Releasing wallet
    2023-09-15T11:02:56Z [fd-wallet37] Releasing wallet
    2023-09-15T11:02:56Z [fd-wallet36] Releasing wallet
    2023-09-15T11:02:56Z [fd-wallet35] Releasing wallet
    2023-09-15T11:02:56Z [fd-wallet34] Releasing wallet
    2023-09-15T11:02:56Z [fd-wallet33] Releasing wallet
    2023-09-15T11:02:56Z [fd-wallet32] Releasing wallet
    2023-09-15T11:02:56Z [fd-wallet31] Releasing wallet
    2023-09-15T11:02:56Z [fd-wallet30] Releasing wallet
    2023-09-15T11:02:56Z [fd-wallet29] Releasing wallet
    2023-09-15T11:02:56Z [fd-wallet28] Releasing wallet
    2023-09-15T11:02:56Z [fd-wallet27] Releasing wallet
    2023-09-15T11:02:56Z [fd-wallet26] Releasing wallet
    2023-09-15T11:02:56Z [fd-wallet25] Releasing wallet
    2023-09-15T11:02:56Z [fd-wallet24] Releasing wallet
    2023-09-15T11:02:56Z [fd-wallet23] Releasing wallet
    2023-09-15T11:02:56Z [fd-wallet22] Releasing wallet
    2023-09-15T11:02:56Z [fd-wallet21] Releasing wallet
    2023-09-15T11:02:56Z [fd-wallet20] Releasing wallet
    2023-09-15T11:02:56Z [fd-wallet19] Releasing wallet
    2023-09-15T11:02:56Z [fd-wallet18] Releasing wallet
    2023-09-15T11:02:56Z [fd-wallet17] Releasing wallet
    2023-09-15T11:02:56Z [fd-wallet16] Releasing wallet
    2023-09-15T11:02:56Z [fd-wallet15] Releasing wallet
    2023-09-15T11:02:56Z [fd-wallet14] Releasing wallet
    2023-09-15T11:02:56Z [fd-wallet13] Releasing wallet
    2023-09-15T11:02:56Z [fd-wallet12] Releasing wallet
    2023-09-15T11:02:56Z [fd-wallet11] Releasing wallet
    2023-09-15T11:02:56Z [fd-wallet10] Releasing wallet
    2023-09-15T11:02:56Z [fd-wallet9] Releasing wallet
    2023-09-15T11:02:56Z [fd-wallet8] Releasing wallet
    2023-09-15T11:02:56Z [fd-wallet7] Releasing wallet
    2023-09-15T11:02:56Z [fd-wallet6] Releasing wallet
    2023-09-15T11:02:56Z [fd-wallet5] Releasing wallet
    2023-09-15T11:02:56Z [fd-wallet4] Releasing wallet
    2023-09-15T11:02:56Z [fd-wallet3] Releasing wallet
    2023-09-15T11:02:56Z [fd-wallet2] Releasing wallet
    2023-09-15T11:02:56Z [fd-wallet1] Releasing wallet
    2023-09-15T11:02:56Z Shutdown: done
    

    </details>

  20. edilmedeiros commented at 10:14 PM on August 2, 2024: contributor

    I'm still cleaning up a script that made me hit this limit, will share it later, but it's not much different from what's in the issue description (creating many wallets in a loop). I'm setting up a signet for an online program with prefunded wallets.

    I'm on macos Sonoma 14.5.

    Can check the limits with.

    $ ulimit -a
    -t: cpu time (seconds)              unlimited
    -f: file size (blocks)              unlimited
    -d: data seg size (kbytes)          unlimited
    -s: stack size (kbytes)             8176
    -c: core file size (blocks)         0
    -v: address space (kbytes)          unlimited
    -l: locked-in-memory size (kbytes)  unlimited
    -u: processes                       2666
    -n: file descriptors                256
    

    Increasing the file descriptors limit for the current shell was simple as (did not required sudo).

    $ ulimit -n 8192
    
    $ ulimit -a
    -t: cpu time (seconds)              unlimited
    -f: file size (blocks)              unlimited
    -d: data seg size (kbytes)          unlimited
    -s: stack size (kbytes)             8176
    -c: core file size (blocks)         0
    -v: address space (kbytes)          unlimited
    -l: locked-in-memory size (kbytes)  unlimited
    -u: processes                       2666
    -n: file descriptors                8192
    

    It does the job for the current shell. Apparently you can't make it unlimited, but can use a large number.

    Doesn't fix bitcoind breaking, but works as a workaround if you can estimate how many files descriptors you're going to need.

  21. edilmedeiros commented at 2:49 PM on October 26, 2024: contributor

    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 require sudo) is a functioning workaround.


github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2026-05-02 18:13 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me