Skip to content
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

view: hack attempting to mitigate split-brain GRPC failures #3291

Merged
merged 1 commit into from
Nov 8, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 19 additions & 5 deletions crates/view/src/worker.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use std::{
collections::BTreeSet,
sync::{Arc, Mutex},
time::Duration,
};

use anyhow::Context;
Expand Down Expand Up @@ -377,12 +378,25 @@ async fn fetch_block(
height: i64,
) -> anyhow::Result<proto::tendermint::types::Block> {
let mut client = TendermintProxyServiceClient::new(channel);
Ok(client
// HACK: this is not a robust long-term solution but may help
// avoid "split-brain" block fetch issues, where a client learns
// of a new block, then immediately tries to fetch it, but that
// fetch is load-balanced over a different node that hasn't yet
// learned about that block.
let rsp = match client
.get_block_by_height(GetBlockByHeightRequest { height })
.await?
.into_inner()
.block
.expect("block not found"))
.await
{
Ok(rsp) => rsp,
Err(e) => {
tracing::warn!(?e, "failed to fetch block, waiting and retrying once");
tokio::time::sleep(Duration::from_secs(1)).await;
client
.get_block_by_height(GetBlockByHeightRequest { height })
.await?
}
};
Ok(rsp.into_inner().block.expect("block not found"))
}

#[cfg(feature = "sct-divergence-check")]
Expand Down
Loading