-
Notifications
You must be signed in to change notification settings - Fork 37.7k
Fix BaseIndex::Commit false error #26903
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
Fix BaseIndex::Commit false error #26903
Conversation
Previously an ERROR was logged every time an index was initialized. Now we only record an error on actual error.
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers. ReviewsSee the guideline for information on the review process.
If your review is incorrectly listed, please react with 👎 to this comment and the bot will ignore it on the next update. 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. |
@MarcoFalke this does also change the behavior slightly |
In |
@MarcoFalke anything that checks the return value will see a different result on the first call. I'm not sure that matters but it is different. |
@MarcoFalke each of the if statements is a single line single expression block |
yes the only thing checking the result from Commit is Rewind, the behavior isn't changed here since Rewind won't be called before m_best_block_index has been set (it asserts that the best block index is the current tip) |
Concept ACK |
I agree 1c67b49 would fix the problem, but I think it suppresses errors too broadly. The I think it would be better to apply a more targeted fix of just not calling --- a/src/index/base.cpp
+++ b/src/index/base.cpp
@@ -189,9 +189,9 @@ void BaseIndex::ThreadSync()
GetName(), pindex->nHeight);
last_log_time = current_time;
}
- if (last_locator_write_time + SYNC_LOCATOR_WRITE_INTERVAL < current_time) {
+ if (pindex->pprev && last_locator_write_time + SYNC_LOCATOR_WRITE_INTERVAL < current_time) {
SetBestBlockIndex(pindex->pprev);
last_locator_write_time = current_time;
// No need to handle errors in Commit. See rationale above.
Commit(); Note on history of this bug: The |
Are you still working on this? |
@mzumsande Maybe you'll want to pick this up? |
I think this worth fixing and could pick it up (might take a week or two), but @ryanofsky since you suggested a specific fix above do you want to PR it? |
f65b0f6 index: Move last_locator_write_time and logging to end of threadsync loop (Fabian Jahr) Pull request description: In the index sync thread, when initializing an index for the first time, stop callng BaseIndex::Commit when m_best_block_index is null, to avoid a spurious "failed to commit" error from that function. This error started happening in commit 7878f97 from #25494 and was reported by pstratem in #26903 with an alternate fix. ACKs for top commit: achow101: ACK f65b0f6 ryanofsky: Code review ACK f65b0f6. Just moved log "Syncing" log line since last commit to avoid having to call now() twice. furszy: ACK f65b0f6 TheCharlatan: ACK f65b0f6 Tree-SHA512: afa8f05786318d36346d167ff53ea0b3bc8abdb0ad04465d199dc3eb91e9f837369e24fcb7e24b5757b02d698ec504e61da6ac365eaf006c874fc07a424a7e20
Removed "Up for Grabs", as this looks like it was fixed in #29671. |
Previously an ERROR was logged every time an index was initialized. Now we only record an error on actual error.