-
Notifications
You must be signed in to change notification settings - Fork 36.5k
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: let Listwalletdir do not iterate through our blocksdata. #19419
Conversation
530c3a2
to
24d2044
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. |
No strong opinion regarding excluding some paths. Current patch needs to be updated (format) and maybe change implementation to use a list of ignore/exclude paths. This can improve GUI by reducing freezes but it's not the right fix for that. When |
yup, ugly quick fix and background thread seams reasonable.. but fix proves the point and lets be honest why should we waste time and risk locks, when traverse trough known node dir?.. . also other GUI freezes should be tackled. |
55e5460
to
6e5b87a
Compare
0a58f3f
to
3d69e4c
Compare
src/wallet/walletutil.cpp
Outdated
fs::path sub_path = GetDataDir(); | ||
|
||
bool we_have_wallets_dir = (wallet_dir != sub_path); | ||
const fs::path fblocks = GetBlocksDir(); |
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.
Instead of multiple variables, you can declare something like const std::vector ignore_paths{ GetBlocksDir(), sub_path / "testnet3", ... }
and then compare against this.
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.
yup 👍 , btw strange how long those bare strings survived refactor, still no global #define BLOCKS_DIR or TESTNET_STR etc.
c49d922
to
4aa7bc5
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
This seems orthogonal to using a background thread. We shouldn't be looking for wallets inside the blocks and chainstate dir even in the background.
src/wallet/walletutil.cpp
Outdated
const fs::path path = it->path().string().substr(offset); | ||
// We dont want to iterate trough those special node dirs | ||
if (it->status().type() == fs::directory_file) { | ||
skip_path = 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.
better to define skip_path
here
Note to other reviewers, the enum file_type: https://www.boost.org/doc/libs/1_66_0/libs/filesystem/doc/reference.html#Enum-file_type
src/wallet/walletutil.cpp
Outdated
it.disable_recursion_pending(); | ||
continue; | ||
} | ||
} else it.disable_recursion_pending(); |
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: just use brackets and newline
Also, I think we should follow symlinks? symlink_file
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.
Following symlinks could create an infinite loop.
src/wallet/walletutil.cpp
Outdated
skip_path = false; | ||
for(const auto& fpath: ignore_paths) { | ||
if (!skip_path && it->path().string().find(fpath.string()) == 0) { | ||
skip_path = true; | ||
} | ||
} | ||
if (skip_path) { | ||
it.disable_recursion_pending(); | ||
continue; | ||
} |
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.
skip_path = false; | |
for(const auto& fpath: ignore_paths) { | |
if (!skip_path && it->path().string().find(fpath.string()) == 0) { | |
skip_path = true; | |
} | |
} | |
if (skip_path) { | |
it.disable_recursion_pending(); | |
continue; | |
} | |
if (ignore_paths.count(it->path()) { | |
it.disable_recursion_pending(); | |
continue; | |
} |
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.
👍 Though I choose
if (std::count(ignore_paths.begin(), ignore_paths.end(), it->path())) {
not sure ignore_paths has a count?
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.
It will once changed to an unordered_set
as suggested
Concept ACK, looks good to me |
Concept ACK, please squash your commits. |
} | ||
} catch (const std::exception& e) { |
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 personally prefer "throwing" versions of the Boost.Filesystem API. But I don't think that combining "throwing" and "non-throwing" versions of the Boost.Filesystem API in the same function is a good design.
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.
with catch boost::exception
and dynamic_cast<std.exception i run with a recursive path in an non catched
EXCEPTION: N5boost10filesystem16filesystem_errorE
so unless u have a hint, i leave it that way, for now?
When WalletDir == DataDir we would have iterate trough our own node files to find wallets, that consumes time and could cause an unresponsive node.
Rebased da6eb3c and addressed reviews. |
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.
Approach ACK da6eb3c.
Mind adding #include <algorithm>
in separate header group?
Designed to be used on ranges of elements.
// software will never create these files but will allow them to be | ||
// opened in a shared database environment for backwards compatibility. | ||
// Add it to the list of available wallets. | ||
paths.emplace_back(it->path().filename()); |
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.
Why did you change this?
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.
its not changed just the correct indent.
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.
If u mean the whole logic itself, its because there where an other wallet access issue not mentioned here fixed also, could be no longer valid since we had some grave changes in master, i have to check, but since the PR its closed yet, it makes sense to let all as is and open two new and or wait until its reopened and then help out with the review.
@@ -5,6 +5,7 @@ | |||
#ifndef BITCOIN_WALLET_WALLETUTIL_H | |||
#define BITCOIN_WALLET_WALLETUTIL_H | |||
|
|||
#include <algorithm> |
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.
Why did you add this here? If it's needed in the .cpp file, put it there...
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.
;was keen to see some compiler warnings, i though that was the hint from @hebasto to add <algorithm>
addressed and changed back to .cpp that other bug we can fix later.
When WalletDir == DataDir we would have iterate trough our own node files to find wallets, that consumes time and could cause an unresponsive node. Diff-minimised Github-Pull: bitcoin#19419 Rebased-From: da6eb3c
🐙 This pull request conflicts with the target branch and needs rebase. Want to unsubscribe from rebase notifications on this pull request? Just convert this pull request to a "draft". |
Marking this as up for grabs. The concept to not iterate needlessly into directories that should not contain wallets definitely makes sense, but I think this makes unnecessary changes that are not well motivated. |
Rebased and addressed 5a8f19e 4fb4fb7 an comments, changed by this a lot so pls review again @luke-jr could not use ur code by merge and lost by fixup ur commit entrys, i hope u don;t mind. https://github.com/Saibato/bitcoin/tree/wallet_351 Since this is closed here the rebase and changes are just in my tree, since github does not update closed pr tyi |
@laanwj "... cause an unresponsive node" in commit message was a hint, this PR is not about to fix something and must not be merged anyway but to point to some lines of code and its implications to gave others a chance to have a look in this and guess by themselfs. in #19502 and #18095 we see some progress, but will that be enough and why have I to write this even, if it is to u so obvious? |
@Saibato GitHub won't let anyone reopen this since your branch changed. Can you Don't forget to rebase! Also: You need to include <set> instead of <algorithm> ;) |
When WalletDir == DataDir we would have iterate trough our own node files to find wallets, that consumes time and could cause an unresponsive node. Github-Pull: bitcoin#19419 Rebased-From: c730c7a
Here's a rebase for later: master...luke-jr:listwalletdir_skip_data |
@luke-jr tyi was the last week just counting my sats and had not looked in this, thx. for the reopen hint. |
When WalletDir == DataDir we would have iterate trough our own node files to find wallets, that consumes time and could cause an unresponsive node. Github-Pull: bitcoin#19419 Rebased-From: c730c7a
Fix: While fiddling with wallets, I noticed that if datadir == walltetsdir an unsynced node can become quite unresponsive.
if no "wallets" dir is in datadir ( i.e. exiting old node )
we would have iterate trough our own node files
to find wallets, that consumes time and could cause an unresponsive node.