-
Notifications
You must be signed in to change notification settings - Fork 38.8k
test: Prevent "Duplicate-wallet filename specified" #14919
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
Conversation
|
Not sure if this is the right fix, IIRC the wallet is removed from the list first and then the actual unload happens. |
|
The relevant code is Lines 3879 to 3883 in 5f23460
The wallet itself has locks to prevent it from being loaded while already loaded, so it seems like an OK fix to me. |
|
@kallewoof that's what happening, it hits that error. It's always the case that after I see 4 solutions:
Note that there are 2 wallet "registries": Lines 69 to 73 in 5f23460
Lines 75 to 84 in 5f23460
|
|
@promag @kallewoof Thank you for the discussion.
I will try this. |
|
@AkioNak you could add an option to diff --git a/test/functional/test_framework/util.py b/test/functional/test_framework/util.py
index d0a78d8df..4af7a51ff 100644
--- a/test/functional/test_framework/util.py
+++ b/test/functional/test_framework/util.py
@@ -201,20 +201,24 @@ def str_to_b64str(string):
def satoshi_round(amount):
return Decimal(amount).quantize(Decimal('0.00000001'), rounding=ROUND_DOWN)
-def wait_until(predicate, *, attempts=float('inf'), timeout=float('inf'), lock=None):
+def wait_until(predicate, *, attempts=float('inf'), timeout=float('inf'), lock=None, ignore_expections=False):
if attempts == float('inf') and timeout == float('inf'):
timeout = 60
attempt = 0
time_end = time.time() + timeout
while attempt < attempts and time.time() < time_end:
- if lock:
- with lock:
+ try:
+ if lock:
+ with lock:
+ if predicate():
+ return
+ else:
if predicate():
return
- else:
- if predicate():
- return
+ except JSONRPCException as e:
+ if not ignore_expections:
+ raise e
attempt += 1
time.sleep(0.05)And then: wait_until(lambda: self.nodes[0].loadwallet(wallet_name), ignore_exceptions=True)BTW, now I'm more fond of
@ryanofsky what are your thoughts? |
I think a better approach would be to make unloadwallet aware that a wallet is unloading and wait for it. It's surprising to me that this would be an asynchronous operation. |
|
@ryanofsky the idea was to not block especially if the wallet is being used or a rescan is going on. In that case the client could timeout and then the problem would be the same — attempt to load would raise |
|
Agree with @ryanofsky. Seems unnecessary to make this call async. If the wallet is in use (e.g. rescan) you should be aware of it and not call unloadwallet. So shouldn't unloadwallet throw an error in that case? |
332983b to
67ccb4f
Compare
wallet_multiwallet.py --usecli may sometimes fails with "Duplicate -wallet filename specified" Unloadwallet RPC command just notify the unload intention and it may delay a little bit until actual unloading. This patch make loadwallet to retry if JSONRPCException occurs.
67ccb4f to
52b380b
Compare
|
Closing in favor of #14941 |
|
@laanwj Please do not close PR:s unless there is inactivity or the author is clearly not cooperating. The authors are perfectly capable of doing this themselves. |
|
@kallewoof I don't think there's a point of having multiple competing PRs open, this spreads discussion around, reopening is always a possibility if discussion goes the other way |
|
I understand your desire to have a clean list of PRs, but there really is no rush on the matter. This PR literally had pushes to it hours before you closed it. If the author judges that the replacement is objectively better they will close their PR on their own, and if they refuse, I see no problem with you making a judgement call like this one. |
|
I'm not sure how you're interpreting it, but for me, closing the PR is only an indication that it's currently not considered for merging. It doesn't delete the discussion, doesn't even prevent replying! it doesn't delete the code changes, etc. That's a typical maintainer task. at least for me it has nothing to do with 'urgency' or capability or non-capability of the author to do it themselves. But anyhow if you insist I'll re-open. |
|
Removing my comment as it strays off topic from the PR. I've sent it to @laanwj in private. |
|
@kallewoof I don't think it makes sense to change the test tree to later revert. There is already agreement to change unloadwallet and @laanwj just closed this in light of that - being closed doesn't mean is locked and dead. |
|
Yes, so I think there's a misunderstanding here: However your PR made us realize that the current |
|
@kallewoof @promag @ryanofsky @MarcoFalke @laanwj Thank you so much. |
|
Thank you @AkioNak for identifying the problem so quick. |
645e905 doc: Add release notes for unloadwallet change to synchronous call (João Barbosa) c37851d rpc: Make unloadwallet wait for complete wallet unload (João Barbosa) Pull request description: Currently the `unloadwallet` RPC is asynchronous, it only signals the intent to unload the wallet and then returns the response to the client. The actual unload can happen later and the client has no way to be notified of that. This PR makes the `unloadwallet` RPC synchronous, meaning that it blocks until the wallet is fully unloaded. Replaces #14919, fixes #14917. Tree-SHA512: ad88b980e2f3652809a58f904afbfe020299f3aa6a517f495ba943b8d54d4520f6e70074d6749be8f5967065c0f476e0faedcde64c8b4899e5f99c70f0fd6534
…unload 645e905 doc: Add release notes for unloadwallet change to synchronous call (João Barbosa) c37851d rpc: Make unloadwallet wait for complete wallet unload (João Barbosa) Pull request description: Currently the `unloadwallet` RPC is asynchronous, it only signals the intent to unload the wallet and then returns the response to the client. The actual unload can happen later and the client has no way to be notified of that. This PR makes the `unloadwallet` RPC synchronous, meaning that it blocks until the wallet is fully unloaded. Replaces bitcoin#14919, fixes bitcoin#14917. Tree-SHA512: ad88b980e2f3652809a58f904afbfe020299f3aa6a517f495ba943b8d54d4520f6e70074d6749be8f5967065c0f476e0faedcde64c8b4899e5f99c70f0fd6534
wallet_multiwallet.py --useclimay sometimes fails with"Duplicate -wallet filename specified"
unloadwallet()RPC command just notify the unload intentionand it may delay a little bit until actual unloading.
This patch check the completion of unloading by using
listwallets().This fixes #14917