-
Notifications
You must be signed in to change notification settings - Fork 36.9k
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: Handle duplicate fileid exception #16923
Conversation
To backport? |
1c55c12
to
8b8964e
Compare
I don't know if that's a thing here but there is no function at the end which returns something (In practice it is). Probably some compilers will give a warning or errer so you might should add a |
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 @promag for working on this.
Note: the PR description should be updated to suggest reviewing with git show -w 8b8964e
Functional test wallet_multiwallet.py --usecli
is failing for me with AssertionError: [node 0] Expected message "BerkeleyBatch: Can't open database w8_copy \(duplicates fileid \w+ from w8\)" does not partially match stderr: ""
Here are the results at 8b8964e of loading 2 identical wallets in ~/.bitcoin/testnet3/wallets/ named t7 and t8:
$ ./src/qt/bitcoin-qt -debug -testnet
terminate called after throwing an instance of 'std::runtime_error'
what(): BerkeleyBatch: Can't open database wallet.dat (duplicates fileid 99059e0100fe00005cbe4ae945270e0000000000 from wallet.dat)
Aborted
$ ./src/bitcoind -testnet -wallet=t7.dat -wallet=t8.dat
2019-09-20T17:55:40Z Bitcoin Core version v0.18.99.0-8b8964e872 (debug build)
...
2019-09-20T17:55:40Z Using data directory /home/jon/.bitcoin/testnet3
2019-09-20T17:55:40Z Using wallet directory /home/jon/.bitcoin/testnet3/wallets
2019-09-20T17:55:40Z init message: Verifying wallet(s)...
2019-09-20T17:55:40Z Using BerkeleyDB version Berkeley DB 4.8.30: (April 9, 2010)
2019-09-20T17:55:40Z Using wallet /home/jon/.bitcoin/testnet3/wallets/t7.dat
2019-09-20T17:55:40Z BerkeleyEnvironment::Open: LogDir=/home/jon/.bitcoin/testnet3/wallets/t7.dat/database
ErrorFile=/home/jon/.bitcoin/testnet3/wallets/t7.dat/db.log
2019-09-20T17:55:40Z scheduler thread start
2019-09-20T17:55:40Z Using BerkeleyDB version Berkeley DB 4.8.30: (April 9, 2010)
2019-09-20T17:55:40Z Using wallet /home/jon/.bitcoin/testnet3/wallets/t8.dat
2019-09-20T17:55:40Z BerkeleyEnvironment::Open: LogDir=/home/jon/.bitcoin/testnet3/wallets/t8.dat/database
ErrorFile=/home/jon/.bitcoin/testnet3/wallets/t8.dat/db.log
01717f5
to
fd576c4
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. |
fd576c4
to
e06614b
Compare
That's not the case, unfortunately. Tested on Linux Mint 19.2:
|
@emilengler I think you mean in |
@hebasto IIRC I tried with no success to hit that, prolly I've done something wrong. |
I can confirm that the fix does not work, unfortunately. Steps to reproduce:
on master:
with this pr:
Literally, I did steps as described in #16776 (comment) |
@promag are you still working on this pr? |
e06614b
to
635f509
Compare
635f509
to
4deb8fa
Compare
@hebasto updated OP, thanks for the remind! |
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.
Tested 4deb8fa on Linux Mint 19.3:
i.e., the exception is handled, but the client keeps trying to load the duplicated wallet forever.
Forever how? |
Run test again: it lasts 2 minutes and keeps going... |
@hebasto I fail to reproduce your case on osx. Does the progress go away when you press "OK" on the "Open wallet failed" dialog? On osx the error dialog shows on top. |
No.
On Linux Mint 19.3 the sequence of events is as follows:
|
ACK a7f81a9, tested on Linux Mint 19.3. |
a7f81a9
to
68e0ff0
Compare
@hebasto improved last commit, no longer wip. |
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.
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.
ACK 68e0ff0 tested rebased on master 5f9cd62
(origin/pr/16923) $ uname -a
Linux 4.19.0-5-amd64 #1 SMP Debian 4.19.37-5+deb10u2 (2019-08-08) x86_64 GNU/Linux
(origin/pr/16923) $ ./src/bitcoind -testnet -wallet=t8-copy.dat -wallet=t8.dat
...
2020-03-30T13:04:17Z Using wallet directory /home/jon/.bitcoin/testnet3/wallets
2020-03-30T13:04:17Z init message: Verifying wallet(s)...
2020-03-30T13:04:17Z Using BerkeleyDB version Berkeley DB 4.8.30: (April 9, 2010)
2020-03-30T13:04:17Z Using wallet /home/jon/.bitcoin/testnet3/wallets/t8-copy.dat
2020-03-30T13:04:17Z BerkeleyEnvironment::Open:
LogDir=/home/jon/.bitcoin/testnet3/wallets/t8-copy.dat/database
ErrorFile=/home/jon/.bitcoin/testnet3/wallets/t8-copy.dat/db.log
2020-03-30T13:04:17Z Using BerkeleyDB version Berkeley DB 4.8.30: (April 9, 2010)
2020-03-30T13:04:17Z Using wallet /home/jon/.bitcoin/testnet3/wallets/t8.dat
2020-03-30T13:04:17Z BerkeleyEnvironment::Open:
LogDir=/home/jon/.bitcoin/testnet3/wallets/t8.dat/database
ErrorFile=/home/jon/.bitcoin/testnet3/wallets/t8.dat/db.log
Attempting to load wallet t8-copy
after loading wallet t8
:
In a follow-up, it might be helpful if the error message stated the conflicting wallet names.
But It says :) yeah display the wallet name, not the underlying filename which is useless for directory based wallets. |
68e0ff0
to
9eefc6e
Compare
Rebased after merging #18338. |
re-ACK 9eefc6e |
9eefc6e gui: Delete progress dialog instead of hidding it (João Barbosa) ee9e88b wallet: Handle duplicate fileid exception (João Barbosa) Pull request description: Handle the duplicate fileid exception thrown at `CheckUniqueFileid` in tow cases: - when duplicate wallets are set on the command line - catch in `LoadWallets`; - when a duplicate wallet is loaded dynamically - catch in `LoadWallet`. Fixes bitcoin#16776. ACKs for top commit: jonatack: Re-ACK 9eefc6e no change since last review 68e0ff0 hebasto: re-ACK 9eefc6e Tree-SHA512: 46e3c1cd6708b54e2d1c4973a74c8d5428822e04cecbc147cf200eb034efa385e867bd749c7c639020e83c9813fae8fed64a851bdd99abf60c33b07e0363f5d5
Summary: Loading two identical wallet files caused a crash > Handle the duplicate fileid exception thrown at CheckUniqueFileid in tow cases: > > - when duplicate wallets are set on the command line - catch in LoadWallets; > - when a duplicate wallet is loaded dynamically - catch in LoadWallet. This is a backport of Core [[bitcoin/bitcoin#16923 | PR16923]] Test Plan: `ninja all check-all` In bitcoin-qt, backup the currently open wallet to a file named wallet.dat, then in the console window type `loadwallet /path/to/wallet/`. Check that the program does not crash and you get a useful error message dialog. Reviewers: #bitcoin_abc, Fabien Reviewed By: #bitcoin_abc, Fabien Differential Revision: https://reviews.bitcoinabc.org/D8898
Handle the duplicate fileid exception thrown at
CheckUniqueFileid
in tow cases:LoadWallets
;LoadWallet
.Fixes #16776.