Multiple bitcoind instances can point to the same -walletdir on Windows #18622

issue mtrycz opened this issue on April 13, 2020
  1. mtrycz commented at 1:28 PM on April 13, 2020: none

    <!-- Describe the issue -->

    I was building Bitcoin Core on my Windows machine, on WSL/Ubuntu. I tried to run the tests and ran into a problem. The test in test/functional/wallet_multiwallet.py failed. Follows the output of the test:

    mtrycz@LAPTOP-00AACAV2:~/git/bitcoin/test/functional$ ./test_runner.py wallet_multiwallet.py
    Temporary test directory at /tmp/test_runner_₿_🏃_20200413_152720
    Remaining jobs: [wallet_multiwallet.py]
    1/1 - wallet_multiwallet.py failed, Duration: 9 s
    
    stdout:
    2020-04-13T13:27:20.407000Z TestFramework (INFO): Initializing test directory /tmp/test_runner_₿_🏃_20200413_152720/wallet_multiwallet_0
    2020-04-13T13:27:24.947000Z TestFramework (INFO): Do not allow -zapwallettxes with multiwallet
    2020-04-13T13:27:25.745000Z TestFramework (INFO): Do not allow -salvagewallet with multiwallet
    2020-04-13T13:27:26.278000Z TestFramework (INFO): Do not allow -upgradewallet with multiwallet
    2020-04-13T13:27:29.060000Z TestFramework (ERROR): Assertion failed
    Traceback (most recent call last):
      File "/home/mtrycz/git/bitcoin/test/functional/test_framework/test_framework.py", line 112, in main
        self.run_test()
      File "/home/mtrycz/git/bitcoin/test/functional/wallet_multiwallet.py", line 152, in run_test
        self.nodes[1].assert_start_raises_init_error(['-walletdir=' + competing_wallet_dir], exp_stderr, match=ErrorMatch.PARTIAL_REGEX)
      File "/home/mtrycz/git/bitcoin/test/functional/test_framework/test_node.py", line 460, in assert_start_raises_init_error
        self._raise_assertion_error(assert_msg)
      File "/home/mtrycz/git/bitcoin/test/functional/test_framework/test_node.py", line 157, in _raise_assertion_error
        raise AssertionError(self._node_msg(msg))
    AssertionError: [node 1] bitcoind should have exited with expected error Error: Error initializing wallet database environment \"\S+competing_walletdir\"!
    2020-04-13T13:27:29.113000Z TestFramework (INFO): Stopping nodes
    2020-04-13T13:27:29.215000Z TestFramework (WARNING): Not cleaning up dir /tmp/test_runner_₿_🏃_20200413_152720/wallet_multiwallet_0
    2020-04-13T13:27:29.215000Z TestFramework (ERROR): Test failed. Test logging available at /tmp/test_runner_₿_🏃_20200413_152720/wallet_multiwallet_0/test_framework.log
    2020-04-13T13:27:29.215000Z TestFramework (ERROR): Hint: Call /home/mtrycz/git/bitcoin/test/functional/combine_logs.py '/tmp/test_runner_₿_🏃_20200413_152720/wallet_multiwallet_0' to consolidate all logs
    
    
    stderr:
    
    
    
    TEST                  | STATUS    | DURATION
    
    wallet_multiwallet.py | ✖ Failed  | 9 s
    
    ALL                   | ✖ Failed  | 9 s (accumulated)
    Runtime: 9 s
    

    I traced the cause to a node being able to open a wallet that is already open by another node.

    To the best of my understanding mutliple bitcoind instances shouldn't be able to point to the same datadirs or walletdirs. On Windows it is possible to have multiple bitcoind instances to point to the same walletdir, leading to possible data corruption. To the best of my understanding this is not possible on Linux (can't confirm atm).

    <!--- What was the actual behavior (provide screenshots if the issue is GUI-related)? -->

    Manual test plan:

    1. Download the latest Windows release binaries (version v.0.19.1)
    2. Create two directories, for example C:\node0 and C:\node1; create a bitcoin.conf file in C:\node1 with a single line rpcport=8333 (otherwise the second node will fail for an unrelated reason)
    3. Open a command prompt and run bitcoind.exe -datadir=C:\node0 -walletdir=D:\bchwallettest
    4. Open a second prompt and run bitcoind.exe -datadir=C:\node1 -walletdir=D:\bchwallettest
    5. Expect the second node to fail at startup

    I've run this test myself and can confirm that the second node erroneously starts. The bug was reproduced on Windows 10 Pro, both in cmd and in WSL shell, with the latest release v.0.19.1.

  2. mtrycz added the label Bug on Apr 13, 2020
  3. emilengler commented at 10:04 AM on April 15, 2020: contributor

    Having a bitcoin.conf with only rpcport set will fail anyway

  4. emilengler commented at 10:05 AM on April 15, 2020: contributor

    Can't reproduce on Debian 10. I get the following error when I start the second node:

    2020-04-15T10:04:42Z ERROR: Error while attempting to lock directory /home/eengler/walletdir: Resource temporarily unavailable
    2020-04-15T10:04:42Z Cannot obtain a lock on wallet directory /home/eengler/walletdir. Another instance of bitcoin may be using it.
    2020-04-15T10:04:42Z Error: Error initializing wallet database environment "/home/eengler/walletdir"!
    Error: Error initializing wallet database environment "/home/eengler/walletdir"!
    

    which is good

  5. meshcollider commented at 10:22 AM on April 18, 2020: contributor

    I can reproduce the wallet_multiwallet.py test failure on WSL. I can also start two nodes pointing to the same data directory with no issue. feature_filelock.py and tool_wallet.py fail for apparently the same reason. Seems like the .lock file is created but is being ignored.

  6. meshcollider added the label Windows on Apr 18, 2020
  7. MarcoFalke added this to the milestone 0.20.0 on Apr 18, 2020
  8. meshcollider commented at 9:30 PM on April 18, 2020: contributor
  9. MarcoFalke removed this from the milestone 0.20.0 on Apr 18, 2020
  10. MarcoFalke added the label Upstream on Apr 18, 2020
  11. laanwj closed this on May 28, 2020

  12. sidhujag referenced this in commit 101dfbf298 on May 29, 2020
  13. ComputerCraftr referenced this in commit 414a47cad7 on Jun 10, 2020
  14. PastaPastaPasta referenced this in commit bc39351780 on Jun 27, 2021
  15. PastaPastaPasta referenced this in commit eb4e0bb582 on Jun 28, 2021
  16. PastaPastaPasta referenced this in commit db1964de24 on Jun 29, 2021
  17. PastaPastaPasta referenced this in commit 72d1c13917 on Jul 1, 2021
  18. PastaPastaPasta referenced this in commit 9307c10712 on Jul 1, 2021
  19. PastaPastaPasta referenced this in commit a5fe159373 on Jul 14, 2021
  20. PastaPastaPasta referenced this in commit afd217904a on Jul 15, 2021
  21. DrahtBot locked this on Feb 15, 2022

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-04-17 00:14 UTC

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