-
Notifications
You must be signed in to change notification settings - Fork 36.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
wallet: Never schedule MaybeCompactWalletDB when -flushwallet is off #18923
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code review ACK fa61954
fa61954
to
9ddddd2
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code review ACK 9ddddd2. 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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Concept ACK |
00000d4
to
faf18d6
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit, if you feel like cleaning it a bit more maybe do this below:
if (env->mapFileUseCount.erase(strFile) == 0) return false
And drop .erase(it)
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, but I'll leave that for a follow-up
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
utACK fa73493
One comment on the new test. Feel free to ignore.
@@ -202,5 +202,10 @@ def run_test(self): | |||
result = self.nodes[0].getaddressinfo(multisig_addr) | |||
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No need for a follow-up. Fast tests are nice too!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
utACK fa73493
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code review ACK fa73493. Just rebased since last review
… -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.