-
Notifications
You must be signed in to change notification settings - Fork 37.7k
index: avoid "failed to commit" errors on initialization #29671
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
Conversation
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers. Code CoverageFor detailed information about the code coverage, see the test coverage report. 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. |
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.
Isn't more natural to move the last locator update to the end of the loop?
I know what you mean by "more natural" but it requires a bigger change because 1. Maybe there is a simpler way to do this refactoring but I am not seeing it right now :) |
Why this is not possible? diff --git a/src/index/base.cpp b/src/index/base.cpp
--- a/src/index/base.cpp (revision aefa9a8fca467ffb26466741f0b6b90289d92e20)
+++ b/src/index/base.cpp (date 1710785794630)
@@ -184,13 +184,6 @@
last_log_time = 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();
- }
-
CBlock block;
interfaces::BlockInfo block_info = kernel::MakeBlockInfo(pindex);
if (!m_chainstate->m_blockman.ReadBlockFromDisk(block, *pindex)) {
@@ -205,6 +198,13 @@
__func__, pindex->GetBlockHash().ToString());
return;
}
+
+ if (last_locator_write_time + SYNC_LOCATOR_WRITE_INTERVAL < current_time) {
+ SetBestBlockIndex(pindex);
+ last_locator_write_time = current_time;
+ // No need to handle errors in Commit. See rationale above.
+ Commit();
+ }
}
}
|
aefa9a8
to
94e36d9
Compare
That works. I misunderstood your comment before, I thought by locator you meant |
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.
self ACK 94e36d9
Could update the PR title and description.
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.
Code review ACK 94e36d9 but I found the PR title and description confusing because "Skip commit during init when nothing can be committed" makes it sounds like this is trying to skip committing when there have been no changes since the last commit, when actually it is trying to skip committing when m_best_block_index
pointer is null and the index is completely empty. Also the title makes this sound like an efficiency improvement, when the actual goal of the PR is to fix is misleading error message. Would suggest title and description more like:
- index: avoid "failed to commit" errors on initialization
- In the index sync thread, when initializing an index for the first time, stop callng
BaseIndex::Commit
whenm_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.
94e36d9
to
87fe47f
Compare
…loop This avoids having commit print a needless error message during init. Co-authored-by: furszy <mfurszy@protonmail.com>
87fe47f
to
f65b0f6
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.
Code review ACK f65b0f6. Just moved log "Syncing" log line since last commit to avoid having to call now() twice.
|
||
auto current_time{std::chrono::steady_clock::now()}; | ||
if (last_log_time + SYNC_LOG_INTERVAL < current_time) { | ||
LogPrintf("Syncing %s with block chain from height %d\n", |
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 agree on the change with a small nuance: now the "syncing index from height " is not entirely accurate. When the log is triggered, the block presented here was already scanned.
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 f65b0f6
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 f65b0f6
ACK f65b0f6 |
…lization 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 bitcoin@7878f97 from bitcoin#25494 and was reported by pstratem in bitcoin#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
…lization 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 bitcoin@7878f97 from bitcoin#25494 and was reported by pstratem in bitcoin#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
…lization 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 bitcoin@7878f97 from bitcoin#25494 and was reported by pstratem in bitcoin#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
…lization 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 bitcoin@7878f97 from bitcoin#25494 and was reported by pstratem in bitcoin#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
…lization 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 bitcoin@7878f97 from bitcoin#25494 and was reported by pstratem in bitcoin#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
…lization 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 bitcoin@7878f97 from bitcoin#25494 and was reported by pstratem in bitcoin#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
fbc0bce Merge bitcoin#29665: build, depends: Fix `libmultiprocess` cross-compilation (fanquake) 59a2145 Merge bitcoin#29747: depends: fix mingw-w64 Qt DEBUG=1 build (fanquake) bdb2fa6 Merge bitcoin#29671: index: avoid "failed to commit" errors on initialization (Ava Chow) 65377ea Merge bitcoin#29192: Weaken serfloat tests (fanquake) 4122404 Merge bitcoin#28891: test: fix `AddNode` unit test failure on OpenBSD (fanquake) 812ef53 Merge bitcoin#25677: refactor: make active_chain_tip a reference (MacroFake) 34e12fa Merge bitcoin#24564: doc: Clarify that CheckSequenceLocksAtTip is a validation function (glozow) d529751 Merge bitcoin#24788: doc: Add gpg key import instructions for Windows (fanquake) 61bae78 Merge bitcoin#24784: refactor: deduplicate integer serialization in RollingBloom benchmark (MarcoFalke) Pull request description: ## Issue being fixed or feature implemented Trivial backports ## What was done? ## How Has This Been Tested? built locally ## Breaking Changes ## Checklist: _Go over all the following points, and put an `x` in all the boxes that apply._ - [ ] I have performed a self-review of my own code - [ ] I have commented my code, particularly in hard-to-understand areas - [ ] I have added or updated relevant unit/integration/functional/e2e tests - [ ] I have made corresponding changes to the documentation - [x] I have assigned this pull request to a milestone _(for repository code-owners and collaborators only)_ ACKs for top commit: UdjinM6: utACK fbc0bce Tree-SHA512: 731f70b747712810d4f74fe64a90139b02ddb62e9ac260705fa2588595feb19bd6e5ffed521fd878bacaab0015683e582fed19ed1855c3e955f93cd223862a17
…loop Summary: This avoids having commit print a needless error message during init. Co-authored-by: furszy <mfurszy@protonmail.com> This is a backport of [[bitcoin/bitcoin#29671 | core#29671]] Depends on D17703 Test Plan: `ninja all check-all` Reviewers: #bitcoin_abc, roqqit Reviewed By: #bitcoin_abc, roqqit Differential Revision: https://reviews.bitcoinabc.org/D17704
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.