Skip to content

Commit 36e1873

Browse files
committed
Bound recovered leader connection attempts
Recovered jobs could stop immediately after logging that their state machine had started. A stale worker address left tonic's connection future pending forever because it had no connection deadline. Apply a 10-second timeout to each attempt while retaining the existing retry and recovery behavior. Exhausted attempts now let the state machine handle the unavailable leader instead of remaining stuck before its first state executes.
1 parent e78f7b5 commit 36e1873

1 file changed

Lines changed: 18 additions & 6 deletions

File tree

crates/arroyo-controller/src/job_controller/leader_manager.rs

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ use tonic::codegen::InterceptedService;
1818
use tonic::transport::Channel;
1919
use tracing::{info, warn};
2020

21+
const LEADER_CONNECT_TIMEOUT: Duration = Duration::from_secs(10);
22+
2123
pub struct LeaderManager {
2224
leader_client: JobStatusGrpcClient<InterceptedService<Channel, InjectWorkerId>>,
2325
pub job_id: JobId,
@@ -35,13 +37,23 @@ impl LeaderManager {
3537
address: String,
3638
) -> anyhow::Result<Self> {
3739
let leader_client = retry!(
38-
job_status_client(
39-
"controller",
40-
&config().worker.tls,
41-
worker_id,
42-
address.clone()
40+
match tokio::time::timeout(
41+
LEADER_CONNECT_TIMEOUT,
42+
job_status_client(
43+
"controller",
44+
&config().worker.tls,
45+
worker_id,
46+
address.clone(),
47+
),
4348
)
44-
.await,
49+
.await
50+
{
51+
Ok(result) => result,
52+
Err(_) => Err(anyhow!(
53+
"timed out connecting to worker leader after {:?}",
54+
LEADER_CONNECT_TIMEOUT
55+
)),
56+
},
4557
5,
4658
Duration::from_millis(100),
4759
Duration::from_secs(2),

0 commit comments

Comments
 (0)