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

Johnny/dp timeout #1720

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
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
37 changes: 37 additions & 0 deletions crates/activate/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,17 @@ async fn apply_changes(
journal_client: &gazette::journal::Client,
shard_client: &gazette::shard::Client,
changes: impl IntoIterator<Item = Change>,
) -> anyhow::Result<()> {
tokio::time::timeout(std::time::Duration::from_secs(60), async {
try_apply_changes(journal_client, shard_client, changes).await
})
.await?
}

async fn try_apply_changes(
journal_client: &gazette::journal::Client,
shard_client: &gazette::shard::Client,
changes: impl IntoIterator<Item = Change>,
) -> anyhow::Result<()> {
let mut journal_deletes = Vec::new();
let mut journal_upserts = Vec::new();
Expand Down Expand Up @@ -295,6 +306,32 @@ async fn converge_task_changes<'a>(
ops_logs_template: Option<&broker::JournalSpec>,
ops_stats_template: Option<&broker::JournalSpec>,
initial_splits: usize,
) -> anyhow::Result<Vec<Change>> {
tokio::time::timeout(std::time::Duration::from_secs(60), async {
try_converge_task_changes(
journal_client,
shard_client,
task_type,
task_name,
template,
ops_logs_template,
ops_stats_template,
initial_splits,
)
.await
})
.await?
}

async fn try_converge_task_changes<'a>(
journal_client: &gazette::journal::Client,
shard_client: &gazette::shard::Client,
task_type: ops::TaskType,
task_name: &str,
template: TaskTemplate<'a>,
ops_logs_template: Option<&broker::JournalSpec>,
ops_stats_template: Option<&broker::JournalSpec>,
initial_splits: usize,
) -> anyhow::Result<Vec<Change>> {
let (list_shards, list_recovery) = list_task_request(task_type, task_name);

Expand Down
25 changes: 25 additions & 0 deletions crates/agent/src/proxy_connectors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,30 @@ impl<L: runtime::LogHandler> ProxyConnectors<L> {
futures::channel::oneshot::Sender<()>,
impl Future<Output = anyhow::Result<()>> + 'a,
),
)> {
Ok(
tokio::time::timeout(DIAL_PROXY_TIMEOUT, self.dial_proxy_inner(data_plane, task))
.await
.with_context(|| {
format!(
"timed out starting proxy connector in data-plane {}",
data_plane.reactor_address
)
})??,
)
}

async fn dial_proxy_inner<'a>(
&'a self,
data_plane: &tables::DataPlane,
task: ops::ShardRef,
) -> anyhow::Result<(
tonic::transport::Channel,
gazette::Metadata,
(
futures::channel::oneshot::Sender<()>,
impl Future<Output = anyhow::Result<()>> + 'a,
),
)> {
let tables::DataPlane {
reactor_address,
Expand Down Expand Up @@ -247,6 +271,7 @@ impl<L: runtime::LogHandler> ProxyConnectors<L> {
}
}

const DIAL_PROXY_TIMEOUT: std::time::Duration = std::time::Duration::from_secs(60); // One minute.
const CONNECTOR_TIMEOUT: std::time::Duration = std::time::Duration::from_secs(300); // Five minutes.

/*
Expand Down
5 changes: 5 additions & 0 deletions crates/gazette/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,11 @@ pub async fn dial_channel(endpoint: &str) -> Result<tonic::transport::Channel> {
.assume_http2(true),
)?;

// Note that this await can block for *longer* than connect_timeout,
// because that timeout only accounts for TCP connection time and does
// not apply to time required to start the HTTP/2 transport.
// This manifests if the server has bound its port but is not serving it.

let channel = match ep.uri().scheme_str() {
Some("unix") => {
ep.connect_with_connector(tower::util::service_fn(|uri: tonic::transport::Uri| {
Expand Down
Loading