2 minor findings · 1 suggestion
Earlier concerns remain unresolved; see the Run archive for their assessments.
Findings
[minor] · Post-install database reopen failures abort the node
A failure in the new post-install database reopen can abort the node rather than restore the backup; no production occurrence was identified.
Location: src/wallet/db.cpp:211 (head).
Details and suggested fix
MoveDatabase closes the staged connection and renames the SQLite database over the original before calling Assert(MakeDatabase(...)). Opening, exclusive-lock acquisition, or verification can return nullptr, which aborts the process instead of reaching the migration exception handler. An authorized concurrent loadwallet can also acquire the exclusive lock in this new close/reopen window because migration does not register in the loading-name guard. The destination then contains SQLite storage with legacy records, so another migratewallet rejects it and the user must restore the surviving .legacy.bak manually. Return the reopen error instead of asserting, and propagate the fact that installation already occurred so rollback removes the installed destination and restores the backup rather than only cleaning the old staging path.
[minor] · Failed staging database creation leaves temporary files behind
If SQLite creates wallet.dat before initialization fails, migration leaves the staging directory behind and can reject a retry within the same second.
Location: src/wallet/wallet.cpp:3841 (head).
Details and suggested fix
sqlite3_open_v2 creates the staging file before exclusive-lock acquisition and schema initialization. If a later step fails, constructor cleanup closes the connection but leaves the file, and MakeDatabase returns nullptr. Consequently, fail() skips new_db->Erase() and only attempts a non-recursive directory removal, which fails because wallet.dat remains. The original wallet is untouched, but repeated failed attempts can accumulate empty or partly initialized staging databases. Register cleanup for this attempt's newly created staging files independently of the returned database pointer, and remove those files before removing the directory.
Optional improvements
[suggestion] · Interrupted migrations leave staging databases in wallet discovery
For wallets under walletdir, an interrupted migration can leave a staging database visible in listwalletdir, and later successful migrations do not remove it.
Location: src/wallet/wallet.cpp:3825 (head).
Details and suggested fix
The staging database receives a recognizable SQLite header and application id before record copying finishes. If the process dies before the move, recursive ListDatabases discovery includes entries such as w/w_sqlite_<t>.tmp, even when the parent directory is itself a wallet. Exceptions that bypass fail() can leave the same artifact. A later migration uses a new timestamp and cleans only its own staging directory, so these entries persist. Add next-migration cleanup for staging directories known to belong to interrupted attempts. Do not use the filename pattern alone to delete or hide them, since a user can legitimately choose a matching wallet name; a scope guard can handle exceptions but cannot replace recovery after process death.