[wallet] when unloading a wallet which still rescans the wallet, the command should fail but bitcoind gets in a buggy state #26463

issue ziggie1984 openend this issue on November 6, 2022
  1. ziggie1984 commented at 3:37 pm on November 6, 2022: none

    I am loading descriptors into bitcoind using the rpcclient with the function: importdescriptors, it automatically starts rescanning the blockchain. Now when I try to unload the wallet, bitcoin-cli will allow me to do it (wallet disappears from the listwallet section, but it will not abort the rescan. Thats a problem bc now when trying to reload the wallet, the wallet sqlite db is locked by bitcoind and this wallet is unusable unitl the rescan is over. abortrescan will not work bc the wallet is not loaded anymore according to bitcoin-cli listwallets. The only solution for me was to delete the wallet dir and create a new wallet with the same name. Now everything works as expected, but as soon as I want to unload the wallet again, bitcoind crashes

    The unloadwallet function should internally abort the rescan and unload the wallet, so that it can be reloaded afterwards without waiting for the rescan. Or it should fail and leading the user to abort the rescan with abortrescan

    • Create a descriptor wallet
    • Import a descriptor and unload the walllet while bitcoind is still rescanning
    • Now you are stuck bc abortrescan will not work bc wallet is not loaded and the only solution is to delete the wallet dir
    • Now Create a new wallet with the same name and import the descriptors again. When the wallet is faster synced then the old process still syncing, and you unload the wallet, bitcoind crashes

    Linux 5.10.103-v8+ [#1529](/bitcoin-bitcoin/1529/) SMP PREEMPT Tue Mar 8 12:26:46 GMT 2022 aarch64 GNU/Linux

    bitcoind v.23.0 (release binary for raspberry pi)

  2. ziggie1984 added the label Bug on Nov 6, 2022
  3. ziggie1984 commented at 3:40 pm on November 6, 2022: none
    @achow101 maybe it works as expected, but according to my feeling unloadwallet should not do anything before the user did not abort the rescan
  4. promag commented at 8:10 pm on December 7, 2022: member

    I am loading descriptors into bitcoind using the rpcclient with the function: importdescriptors, it automatically starts rescanning the blockchain. Now when I try to unload the wallet,

    you interrupted bitcoin-cli importdescriptors right?

    bitcoin-cli will allow me to do it (wallet disappears from the listwallet section, but it will not abort the rescan

    and you also interrupted bitcoin-cli unloadwallet right?

    These calls are blocking, interrupting on the command line doesn’t interrupt on server side. Internally there is a thread scanning the chain and there is a thread waiting for unload release.

    The unloadwallet function should internally abort the rescan and unload the wallet, so that it can be reloaded afterwards without waiting for the rescan. Or it should fail and leading the user to abort the rescan with abortrescan

    IMO it should just fail.

  5. ziggie1984 commented at 11:39 pm on December 7, 2022: none

    Yes and Yes.

    Yes I think we maybe should just fail as long as the wallet in rescanning. Otherwise the is no option to escape and the unloadwallet command is not recoverable. So definitely on your side.

  6. achow101 closed this on Jan 9, 2023

  7. sidhujag referenced this in commit 1ab8c80040 on Jan 10, 2023
  8. bitcoin locked this on Jan 9, 2024


ziggie1984 promag

Labels
Bug


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-11-17 12:12 UTC

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