fix: Propagate JSONL import parse and verify failures#5242
Open
Officeyutong wants to merge 1 commit into
Open
fix: Propagate JSONL import parse and verify failures#5242Officeyutong wants to merge 1 commit into
Officeyutong wants to merge 1 commit into
Conversation
chenyukang
force-pushed
the
fix-ckb-import
branch
from
July 3, 2026 08:36
e6bc5d0 to
240fe0a
Compare
Collaborator
|
@codex Review. |
Contributor
There was a problem hiding this comment.
Pull request overview
This PR hardens ckb import of JSONL/JSONL-gz block data by ensuring JSON parsing, line-read failures, and background parsing/verification outcomes are properly propagated back to the import result instead of being hidden, ignored, or causing hangs/panics.
Changes:
- Replace first-line
expectparsing with proper error propagation for empty/malformed input. - Make the JSONL parser thread return
Resultand join it from the main import path to surface parse/read/send failures. - Replace “poll largest height” waiting with a channel-based mechanism that waits for verification callbacks from all submitted blocks.
Comment on lines
+206
to
220
| Box::new(move |verify_result: VerifyResult| match verify_result { | ||
| Ok(true) => { | ||
| progress_bar.inc(block_size as u64); | ||
| let _ = verify_tx.send(Ok(block_number)); | ||
| } | ||
| Ok(false) => { | ||
| let _ = verify_tx | ||
| .send(Err(format!("block {block_number} was not verified"))); | ||
| } | ||
| Err(err) => { | ||
| eprintln!("Error verifying block: {:?}", err); | ||
| let _ = verify_tx | ||
| .send(Err(format!("verify block {block_number} failed: {err:?}"))); | ||
| } | ||
| }) |
Comment on lines
+227
to
240
| Box::new(move |verify_result: VerifyResult| match verify_result { | ||
| Ok(true) => { | ||
| let _ = verify_tx.send(Ok(block_number)); | ||
| } | ||
| Ok(false) => { | ||
| let _ = verify_tx | ||
| .send(Err(format!("block {block_number} was not verified"))); | ||
| } | ||
| Err(err) => { | ||
| eprintln!("Error verifying block: {:?}", err); | ||
| let _ = verify_tx | ||
| .send(Err(format!("verify block {block_number} failed: {err:?}"))); | ||
| } | ||
| }) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What problem does this PR solve?
Issue Number: close #xxx
Problem Summary:
ckb importparsed JSONL blocks in a background thread, but several failure paths were not propagated to the import result.Malformed JSON on the first line used
expectand could panic. Later malformed lines were parsed inside a spawned thread whoseJoinHandlewas dropped, so parser panics or errors were not reported to the main import path. Line read errors were also discarded withfilter_map(Result::ok). After submitting blocks, the import loop only waited for the largest block number to appear in the database, while verification errors were only printed from the callback. This could lead to panic, silent partial import, or an indefinite wait when a submitted block failed verification.What is changed and how it works?
Proposal: xxx
What's Changed:
Return structured errors for first-line parsing, make the parser thread return
Result, and join it from the main import path. JSONL read, parse, and send failures are now propagated instead of being ignored or hidden in a detached thread.Verification callbacks now report their result through a channel. The import command waits for callbacks from all submitted non-genesis blocks and returns an error for verification failure or
Ok(false). This replaces the previous largest-height polling loop, so failed imports terminate with an explicit error instead of hanging.Related changes
owner/repo:Check List
Tests
Side effects