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

issue mtrycz openend this issue on April 13, 2020
  1. mtrycz commented at 1:28 pm on April 13, 2020: none

    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:

     0mtrycz@LAPTOP-00AACAV2:~/git/bitcoin/test/functional$ ./test_runner.py wallet_multiwallet.py
     1Temporary test directory at /tmp/test_runner_₿_🏃_20200413_152720
     2Remaining jobs: [wallet_multiwallet.py]
     31/1 - wallet_multiwallet.py failed, Duration: 9 s
     4
     5stdout:
     62020-04-13T13:27:20.407000Z TestFramework (INFO): Initializing test directory /tmp/test_runner_₿_🏃_20200413_152720/wallet_multiwallet_0
     72020-04-13T13:27:24.947000Z TestFramework (INFO): Do not allow -zapwallettxes with multiwallet
     82020-04-13T13:27:25.745000Z TestFramework (INFO): Do not allow -salvagewallet with multiwallet
     92020-04-13T13:27:26.278000Z TestFramework (INFO): Do not allow -upgradewallet with multiwallet
    102020-04-13T13:27:29.060000Z TestFramework (ERROR): Assertion failed
    11Traceback (most recent call last):
    12  File "/home/mtrycz/git/bitcoin/test/functional/test_framework/test_framework.py", line 112, in main
    13    self.run_test()
    14  File "/home/mtrycz/git/bitcoin/test/functional/wallet_multiwallet.py", line 152, in run_test
    15    self.nodes[1].assert_start_raises_init_error(['-walletdir=' + competing_wallet_dir], exp_stderr, match=ErrorMatch.PARTIAL_REGEX)
    16  File "/home/mtrycz/git/bitcoin/test/functional/test_framework/test_node.py", line 460, in assert_start_raises_init_error
    17    self._raise_assertion_error(assert_msg)
    18  File "/home/mtrycz/git/bitcoin/test/functional/test_framework/test_node.py", line 157, in _raise_assertion_error
    19    raise AssertionError(self._node_msg(msg))
    20AssertionError: [node 1] bitcoind should have exited with expected error Error: Error initializing wallet database environment \"\S+competing_walletdir\"!
    212020-04-13T13:27:29.113000Z TestFramework (INFO): Stopping nodes
    222020-04-13T13:27:29.215000Z TestFramework (WARNING): Not cleaning up dir /tmp/test_runner_₿_🏃_20200413_152720/wallet_multiwallet_0
    232020-04-13T13:27:29.215000Z TestFramework (ERROR): Test failed. Test logging available at /tmp/test_runner_₿_🏃_20200413_152720/wallet_multiwallet_0/test_framework.log
    242020-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
    25
    26
    27stderr:
    28
    29
    30
    31TEST                  | STATUS    | DURATION
    32
    33wallet_multiwallet.py | ✖ Failed  | 9 s
    34
    35ALL                   | ✖ Failed  | 9 s (accumulated)
    36Runtime: 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).

    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:

    02020-04-15T10:04:42Z ERROR: Error while attempting to lock directory /home/eengler/walletdir: Resource temporarily unavailable
    12020-04-15T10:04:42Z Cannot obtain a lock on wallet directory /home/eengler/walletdir. Another instance of bitcoin may be using it.
    22020-04-15T10:04:42Z Error: Error initializing wallet database environment "/home/eengler/walletdir"!
    3Error: 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: 2024-12-23 03:12 UTC

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