wallet: PeriodicFlush called when mapFileUseCount is empty #19175

issue fanquake openend this issue on June 5, 2020
  1. fanquake commented at 11:56 am on June 5, 2020: member

    I noticed while reviewing #19085, if the wallet is due to perform a PeriodicFlush(), but in the 2 second delay, another action occurs, i.e a call to backupwallet, the flushing never happens.

    The wallet does get flushed and db closed as part of backupwallet (remains loaded); however this leaves the scheduler running MaybeCompactWalletDB continually trying to flush the wallet, which now always fails because mapFileUseCount is empty.

    Note that generally, when MaybeCompactWalletDB is called, nothing is done because:

    https://github.com/bitcoin/bitcoin/blob/aa35ea55021dbb7f35a00fd666903d9fd03b88e7/src/wallet/walletdb.cpp#L966

    is false. However in this case, it’s true, and we do continually descend into PeriodicFlush().

    This is resolved whenever the next wallet related action occurs, i.e a call to getwalletinfo, as mapFileUseCount is repopulated, and PeriodicFlush() succeeds.

    I don’t know the wallet code well enough to know if this is a problem, or just an implementation quirk.

  2. fanquake added the label Wallet on Jun 5, 2020
  3. jnewbery commented at 6:09 pm on June 5, 2020: contributor
    I think it’s just an implementation quirk and won’t prevent the wallet from being flushed when needed, but at the very least, there should be comments in MaybeCompactWalletDB() and for the nUpdateCounter, nLastSeen, nLastFlushed and nLastWalletUpdate data members.
  4. willcl-ark closed this on Sep 21, 2023

  5. bitcoin locked this on Sep 20, 2024

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 09:12 UTC

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