Unverified Commit 5288ca3c authored by asynchronous rob's avatar asynchronous rob Committed by GitHub
Browse files

check for lost race before warning (#2833)

parent b3fd82f7
Pipeline #133229 failed with stages
in 24 minutes and 19 seconds
......@@ -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());
},
......
Supports Markdown
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