Repository navigation
fix(workflow): retry server-sent CANCELLED during orchestration waits (closes #1246) #1370
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
base: main
Are you sure you want to change the base?
Changes from all commits
bcddae9
8882932
8260cf1
fa01cd3
8b3dd22
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -793,3 +793,23 @@ async def rerun_workflow_from_event_with_result( | |
| app_id=app_id, | ||
| ) | ||
| return WorkflowRerunResult(new_instance_id=res.newInstanceID, staged=res.staged) | ||
|
|
||
| @property | ||
| def is_closed(self) -> bool: | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This adds
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Definitely — added tests covering I also added |
||
| """Returns True if the client has been closed.""" | ||
| return self.__obj.is_closed | ||
|
|
||
| async def aclose(self): | ||
| """Closes the gRPC connection used by the client.""" | ||
| await self.__obj.aclose() | ||
|
|
||
| async def close(self): | ||
| """Closes the gRPC connection used by the client.""" | ||
| await self.aclose() | ||
|
|
||
| async def __aenter__(self): | ||
| return self | ||
|
|
||
| async def __aexit__(self, exc_type, exc_val, exc_tb): | ||
| await self.aclose() | ||
| return False | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
With an unbounded wait, any
CANCELLEDthat took at least 1s clearstransient_deadline, so nothing caps how many times we retry. If something between the client and daprd always cancels after a second or more (a proxy idle timeout, an interceptor, a daprd stuck in a restart loop),wait_for_orchestration_completion(timeout=0)keeps retrying forever, logging only warnings. Before this change, the 30s window always ended in an error. What do you think about capping the number of resets in a row (or the total time spent retrying), or at least logging at a higher level when the window resets? A test where every attempt isCANCELLEDafter more than 1s would pin down whichever behaviour we choose. The same applies to the async client ataio/client.pyline 324.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Really sharp catch on the unbounded wait loop when a proxy or restart cycle keeps cancelling.
I went with capping consecutive in-flight resets: added
_MAX_CONSECUTIVE_TRANSIENT_RESETS = 3to both sync and async clients. If cancellations keep arriving after >=1s, the 30s grace window is refreshed up to 3 times (with a warning log showing the count). Once the cap is reached, the window no longer extends, allowing persistent failure modes to surface the realRpcErrorinstead of spinning forever.Added regression tests in
test_orchestration_wait.pyandtest_client_async.pyverifying that continuous in-flight cancellations eventually propagate.