wallet: Never schedule MaybeCompactWalletDB when -flushwallet is off#18923
wallet: Never schedule MaybeCompactWalletDB when -flushwallet is off#18923meshcollider merged 5 commits intobitcoin:masterfrom
Conversation
|
Can be tested by applying the following diff and observing a failing test: diff --git a/test/functional/wallet_dump.py b/test/functional/wallet_dump.py
index 6bfb468823..f30589761a 100755
--- a/test/functional/wallet_dump.py
+++ b/test/functional/wallet_dump.py
@@ -190,7 +190,7 @@ class WalletDumpTest(BitcoinTestFramework):
assert_raises_rpc_error(-8, "already exists", lambda: self.nodes[0].dumpwallet(wallet_enc_dump))
# Restart node with new wallet, and test importwallet
- self.restart_node(0, ['-wallet=w2'])
+ self.restart_node(0, ['-wallet=w2', '-flushwallet=0'])
# Make sure the address is not IsMine before import
result = self.nodes[0].getaddressinfo(multisig_addr) |
fa5be60 to
fabdbbf
Compare
|
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers. ConflictsReviewers, this pull request conflicts with the following ones:
If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first. |
fabdbbf to
fa4dca2
Compare
fa07b86 to
fa61954
Compare
ryanofsky
left a comment
There was a problem hiding this comment.
Code review ACK fa6195467a3533fcdcc001d559555a86717cd5d3
fa61954 to
9ddddd2
Compare
ryanofsky
left a comment
There was a problem hiding this comment.
Code review ACK 9ddddd2d927b3a752e4698c4771fc68cdc2d9698. SInce last review was changed to pass periodic flush option from WalletInit::Construct
9ddddd2 to
fa4689f
Compare
fa4689f to
00000d4
Compare
There was a problem hiding this comment.
Code review ACK 00000d48588689f7576a8f4cbd9eb8edee3b53b0. No important suggestions. First two commits are the same since last review, last commit is basically the same, middle commits switch back to passing ArgsManager instead of the bool, but going through WalletContext struct from #19096
|
Concept ACK |
00000d4 to
faf18d6
Compare
fac1736 to
fafc7d4
Compare
|
Rebased |
Its only purpose is to create a directory. So instead of keeping it alive, use it only to get the path of the directory and then create it explicitly.
This refactor does not change behavior
fafc7d4 to
fa73493
Compare
| for (auto it = env->mapFileUseCount.begin() ; it != env->mapFileUseCount.end(); it++) { | ||
| if ((*it).second > 0) return false; | ||
| for (const auto& use_count : env->mapFileUseCount) { | ||
| if (use_count.second > 0) return false; |
There was a problem hiding this comment.
nit, if you feel like cleaning it a bit more maybe do this below:
if (env->mapFileUseCount.erase(strFile) == 0) return falseAnd drop .erase(it).
There was a problem hiding this comment.
Thanks, but I'll leave that for a follow-up
| assert result['ismine'] | ||
|
|
||
| self.log.info('Check that wallet is flushed') | ||
| with self.nodes[0].assert_debug_log(['Flushing wallet.dat'], timeout=20): |
There was a problem hiding this comment.
I know you'll disagree, but I think it's always better to test the result of an action rather than whether it was logged. In this case, I think you could test the file modification time before and after.
There was a problem hiding this comment.
I think both can be done at the same time, but asserting the modification time increases requires a time.sleep(1), since os.path.getmtime returns seconds. I don't like sleeps longer than 200 ms in tests, so I'll leave that for a follow-up ;)
There was a problem hiding this comment.
No need for a follow-up. Fast tests are nice too!
… -flushwallet is off fa73493 refactor: Use C++11 range-based for loop (MarcoFalke) fa7b164 wallet: Never schedule MaybeCompactWalletDB when -flushwallet is off (MarcoFalke) faf8401 wallet: Pass unused args to StartWallets (MarcoFalke) fa6c186 gui tests: Limit life-time of dummy testing setup (MarcoFalke) fa28a61 test: Add smoke test to check that wallets are flushed by default (MarcoFalke) Pull request description: User-facing, this is a refactor. Internally, the scheduler does not have to call a mostly empty function every half a second. ACKs for top commit: jnewbery: utACK fa73493 meshcollider: utACK fa73493 ryanofsky: Code review ACK fa73493. Just rebased since last review Tree-SHA512: 99e1fe1b2c22a3f4b19de3e566241d38693f4fd8d5a68ba1838d86740aa6c08e3325c11a072e30fd262a8861af4278bed52eb9374c85179b8f536477f528247c
Summary: ``` User-facing, this is a refactor. Internally, the scheduler does not have to call a mostly empty function every half a second. ``` Backport of core [[bitcoin/bitcoin#18923 | PR18923]]. Test Plan: ninja all check-all Reviewers: #bitcoin_abc, deadalnix Reviewed By: #bitcoin_abc, deadalnix Differential Revision: https://reviews.bitcoinabc.org/D8638
User-facing, this is a refactor. Internally, the scheduler does not have to call a mostly empty function every half a second.