Skip to content
Snippets Groups Projects
Commit 8eae0fa4 authored by asynchronous rob's avatar asynchronous rob Committed by GitHub
Browse files

check for lost race before warning (#2833)

parent 1e451780
Branches
No related merge requests found
......@@ -636,13 +636,26 @@ pub(crate) async fn handle_new_head(
match imported_block_info(ctx, env, block_hash, &block_header).await? {
Some(i) => imported_blocks_and_info.push((block_hash, block_header, i)),
None => {
// Such errors are likely spurious, but this prevents us from getting gaps
// in the approval-db.
tracing::warn!(
target: LOG_TARGET,
"Unable to gather info about imported block {:?}. Skipping chain.",
(block_hash, block_header.number),
);
// It's possible that we've lost a race with finality.
let (tx, rx) = oneshot::channel();
ctx.send_message(
ChainApiMessage::FinalizedBlockHash(block_header.number.clone(), tx).into()
).await;
let lost_to_finality = match rx.await {
Ok(Ok(Some(h))) if h != block_hash => true,
_ => false,
};
if !lost_to_finality {
// Such errors are likely spurious, but this prevents us from getting gaps
// in the approval-db.
tracing::warn!(
target: LOG_TARGET,
"Unable to gather info about imported block {:?}. Skipping chain.",
(block_hash, block_header.number),
);
}
return Ok(Vec::new());
},
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment