Skip to content

wallet: PeriodicFlush called when mapFileUseCount is empty #19175

@fanquake

Description

@fanquake

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:

if (dbh.nLastFlushed != nUpdateCounter && GetTime() - dbh.nLastWalletUpdate >= 2) {

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions