wallet: let Listwalletdir do not iterate through our blocksdata.#19419
wallet: let Listwalletdir do not iterate through our blocksdata.#19419Saibato wants to merge 2 commits intobitcoin:masterfrom
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
There was a problem hiding this comment.
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.
yup 👍 , btw strange how long those bare strings survived refactor, still no global #define BLOCKS_DIR or TESTNET_STR etc.
c49d922 to
4aa7bc5
Compare
Sjors
left a comment
There was a problem hiding this comment.
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.
| 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.
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
| it.disable_recursion_pending(); | ||
| continue; | ||
| } | ||
| } else it.disable_recursion_pending(); |
There was a problem hiding this comment.
nit: just use brackets and newline
Also, I think we should follow symlinks? symlink_file
There was a problem hiding this comment.
Following symlinks could create an infinite loop.
| 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.
| 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.
👍 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.
It will once changed to an unordered_set as suggested
|
Concept ACK, looks good to me |
|
Concept ACK, please squash your commits. |
There was a problem hiding this comment.
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.
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. |
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.
its not changed just the correct indent.
There was a problem hiding this comment.
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.
| #ifndef BITCOIN_WALLET_WALLETUTIL_H | ||
| #define BITCOIN_WALLET_WALLETUTIL_H | ||
|
|
||
| #include <algorithm> |
There was a problem hiding this comment.
Why did you add this here? If it's needed in the .cpp file, put it there...
There was a problem hiding this comment.
;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: c730c7a6b6eb9f2e5138e2874ca7c5c269086bf3
|
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: c730c7a6b6eb9f2e5138e2874ca7c5c269086bf3
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.