Skip to content

feat: retry coordinator-to-worker channel setup + fix 2 bugs - #712

Open
gabotechs wants to merge 4 commits into
gabrielmusat/add-dialer-based-route-task-handlerfrom
gabrielmusat/add-retry-mechanism
Open

feat: retry coordinator-to-worker channel setup + fix 2 bugs#712
gabotechs wants to merge 4 commits into
gabrielmusat/add-dialer-based-route-task-handlerfrom
gabrielmusat/add-retry-mechanism

Conversation

@gabotechs

@gabotechs gabotechs commented Sep 7, 2026

Copy link
Copy Markdown
Collaborator

Builds on top of

And adds 4 individual commits:

  1. Some improvements to the chaos test, to try to make results a bit more catastrophic
  2. Adds some retry mechanism that reacts to gRPC status codes and retries the coordinator->worker channels
  3. Fix one bug surfaced by the chaos test: when retrying, the same TaskKey might be attempted to be written multiple times, making the SingleWriteMultipleRead struct fail on the second write. With this change, the second write just overrides the previous one.
  4. Fix another bug surfaced by the chaos test: when retrying, there's a chance that two tasks fall on the same worker. If that happens there's a caching collision in the WorkerConnectionPool, where retrieving two different non-overlapping ranges of partitions will go through the same cached stream, trying to consume it multiple times.

Comment on lines +83 to +95
// https://grpc.io/docs/guides/status-codes/#deadline-exceeded
// The worker may be slow or wedged, so retry a different URL.
Code::DeadlineExceeded => RetryOutcome::OtherUrl.tag(err),
// https://grpc.io/docs/guides/status-codes/#resource-exhausted
// Admission pressure is local to this worker, so retry a different URL.
Code::ResourceExhausted => RetryOutcome::OtherUrl.tag(err),
// https://grpc.io/docs/guides/status-codes/#aborted
// Routing retries this task setup at the higher level on the same URL.
Code::Aborted => RetryOutcome::SameUrl.tag(err),
// https://grpc.io/docs/guides/status-codes/#unavailable
// This is a transient failure; retry the task setup on the same URL.
Code::Unavailable => RetryOutcome::SameUrl.tag(err),
Code::Ok => err,

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tbh, I don't know what I'm doing here... there's probably a better retry policy for this.

Invoking @hermeGarcia, in the hopes that you have better suggestions about how to transparently handle retries here.

Comment on lines 59 to 61
self.tx.send_modify(|v| {
if v.is_none() {
if v.is_none() || !*read_started {
*v = Some(item);

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fix for bug 1: if nobody has read yet the value, we are good to replace it.

Comment on lines -24 to +27
/// - Lazy inits connections to a remote worker on first call to [WorkerConnectionPool::execute].
/// - Lazily initializes connections per remote worker and requested partition range.
pub(crate) struct WorkerConnectionPool {
lazy_stream_groups: Vec<OnceLock<SharedBoxFuture<StreamGroup>>>,
lazy_stream_groups: Vec<DashMap<Range<usize>, SharedBoxFuture<StreamGroup>>>,

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fix for bug 2: if two requests come for the same target task, we still need to discriminate between requested partition ranges.

@gabotechs gabotechs changed the title feat: retry coordinator-to-worker channel setup feat: retry coordinator-to-worker channel setup + fix 2 bugs Sep 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant