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: Improve log output for errors during load #15491
wallet: Improve log output for errors during load #15491
Conversation
4b4127b
to
e5637b1
Compare
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers. ConflictsNo conflicts as of last run. |
tACK e5637b1 I now get a flood of this with one my broken wallets: 2019-02-27T08:32:30Z [default wallet] CDataStream::read(): end of data: unspecified iostream_category error
2019-02-27T08:32:30Z [default wallet] CDataStream::read(): end of data: unspecified iostream_category error
2019-02-27T08:32:30Z [default wallet] CDataStream::read(): end of data: unspecified iostream_category error |
@Sjors Yep, that's the same thing I get -- at least in my case, each of those is a 'keymeta' entry, whose value is missing the final has_key_origin field of CKeyMetaData. I think the flood of log entries is definitely better than the lack of any, although the volume is a little annoying (but I think it makes sense when encountering a broken wallet file to be verbose about it.) |
It's fine. This is the type of error that should really never happen in the real world, so indeed when it does, the more information the better. |
@Sjors frankly these type of changes are mostly for developer's sanity. I've run into similar issues with wallet entries and felt compelled to upstream changes. |
utACK e5637b1 |
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.
Does it make sense to commit some broken wallets to the repo?
e5637b1
to
3bd35f2
Compare
The idea of committing a broken wallet as a test case makes sense to me, but (1) I seem to recall I've heard people say in past cases that committing a binary wallet file to the repo is not reasonable even as test data, and (2) I definitely don't know how to go about minimizing such a test case, which seems both necessary and painful. |
3bd35f2
to
0eea55f
Compare
Rebased. |
Restarted travis job 6 - failed on commit 4e7fea2 with:
|
Yeah, I think switching to absolute path would make sense. I assume I just need to switch from GetName to GetPath. Will try it out. |
0eea55f
to
aa711d9
Compare
Switched to GetPath().string() instead of GetName(). Removed the rename to log_wallet_name, in the interest of minimizing the size of the diff, since it is once again a wallet file name. (I can reinstate the rename if preferred.) |
Oh, no, this didn't do what I wanted at all. On further inspection of #15334, it doesn't actually log the absolute path, it just logs the filename, but more importantly it doesn't use WalletLocation::GetPath, but it has some other place it's getting this info. GetPath is giving me the wallet directory, excluding the filename, it seems. Can someone clue me in to the exact semantics / interpretation of the name and path in WalletLocation? Can I just slap "wallet.dat" on the end of the output of GetPath and be good, or are there other cases? |
I'd suggest adding a new method to the + fs::path DataFilePath() const { return env->Directory() / strFile; } and printing the path with |
aa711d9
to
7cf7290
Compare
@ryanofsky I ended up taking a slightly different approach, because at this point we do not have a CWallet yet to get a db handle from (we are in the flow to open one.) Instead, I added a free function for normalizing paths. (I could have accomplished the same thing without adding a function, by calling SplitWalletPath (but it's static, and a slightly weird interface for this) or GetWalletEnv (but it's a very weird interface for this, and also it manipulates g_dbenvs, which I don't know the consequences of and seems a little heavy-handed for just figuring out a path.) |
Looks good if you s/wallet database file/data file path/ and s/FullWalletFilePath/WalletDataFilePath/. I'd suggest: /** Given a wallet directory path or legacy file path, return path to main data file in the wallet database. */
fs::path WalletDataFilePath(const fs::path& wallet_path); Wallet databases are really directories, not files. At a low level, wallet databases include not just The only reason it makes sense to reference files instead of directories in log messages is to disambiguate in the legacy case where there can be multiple data files for different wallets stored in the same directory and sharing mixed log files. (This was a misfeature which is mostly removed, except we still support loading these wallets in the top level walletdir.) |
Got it, thanks @ryanofsky , makes sense. Changed as suggested! |
7cf7290
to
17d0114
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.
utACK 17d0114
It would be good to update the PR description #15491 (comment) which still references "[default wallet]".
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 17d0114.
src/wallet/db.cpp
Outdated
@@ -84,6 +84,13 @@ bool IsWalletLoaded(const fs::path& wallet_path) | |||
return database && database->IsDatabaseLoaded(database_filename); | |||
} | |||
|
|||
fs::path WalletDataFilePath(const fs::path& wallet_path) { |
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, {
should be in new line.
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.
Curses, done.
I'm afraid my brain is stuck in the wrong style for life, sorry.
When loading the wallet, display the entire path in error messages, instead of the name (which, for the default wallet, is the empty string.) When an exception occurs during wallet loading, display e.what() if possible, instead of nothing.
17d0114
to
faf3698
Compare
Fixed the PR description. Fixed the brace @promag was complaining about. No other changes. |
utACK faf3698 |
faf3698 wallet: Improve log output for errors during load (Glenn Willen) Pull request description: When loading the wallet, display the entire path in error messages, instead of the name (which, for the default wallet, is the empty string.) When an exception occurs during wallet loading, display e.what() if possible, instead of nothing. Tree-SHA512: 435247628db669579bb694ba4b53ba174fe42c0329fc72f09fc274bb28463ee69f53412abb2a3b45bb8f59f7eb928c0167e397b8d0a514135142192a87294614
faf3698 wallet: Improve log output for errors during load (Glenn Willen) Pull request description: When loading the wallet, display the entire path in error messages, instead of the name (which, for the default wallet, is the empty string.) When an exception occurs during wallet loading, display e.what() if possible, instead of nothing. Tree-SHA512: 435247628db669579bb694ba4b53ba174fe42c0329fc72f09fc274bb28463ee69f53412abb2a3b45bb8f59f7eb928c0167e397b8d0a514135142192a87294614
When loading the wallet, display the entire path in error messages, instead of
the name (which, for the default wallet, is the empty string.)
When an exception occurs during wallet loading, display e.what() if possible,
instead of nothing.