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

Make sure workflow_failed is incremented on NonDeterministicException #2141

Merged
merged 2 commits into from
Jul 9, 2024

Conversation

Quinn-With-Two-Ns
Copy link
Contributor

Make sure workflow_failed is incremented on NonDeterministicException

closes #2103

@Quinn-With-Two-Ns Quinn-With-Two-Ns requested a review from a team as a code owner July 8, 2024 23:22
@@ -255,10 +255,14 @@ private void applyServerHistory(long lastEventId, WorkflowHistoryIterator histor
implementationOptions.getFailWorkflowExceptionTypes();
for (Class<? extends Throwable> failType : failTypes) {
if (failType.isAssignableFrom(e.getClass())) {
metricsScope.counter(MetricsType.WORKFLOW_FAILED_COUNTER).inc(1);
Copy link
Member

Choose a reason for hiding this comment

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

I see completeWorkflow increments this metric. Do these exceptions not make it to completeWorkflow? Is there a common place that completeWorkflow-based exceptions and these are turned to workflow failures that may be a better place to move the metric, e.g. WorkflowStateMachines.failWorkflow? Or even if we don't want to change completeWorkflow, is there a common place where WorkflowExecutionException is caught and converted?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Do these exceptions not make it to completeWorkflow

Correct, this code catches exceptions from the state machine, not the workflow code itself

Is there a common place that completeWorkflow-based exceptions and these are turned to workflow failures that may be a better place to move the metric, e.g. WorkflowStateMachines.failWorkflow

No

is there a common place where WorkflowExecutionException is caught and converted?

The only place would be when the SDK responds to the server, but that would require changing where all completion metrics are emitted. That work is captured here #1590. I was hopping to defer that work till later.

throw new WorkflowExecutionException(
workflow.getWorkflowContext().mapWorkflowExceptionToFailure(e));
}
}
if (e instanceof WorkflowExecutionException) {
Copy link
Member

Choose a reason for hiding this comment

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

Curious, what is the situation where e is a WorkflowExecutionException here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't think it can happen today, but if workflowStateMachines.handleEvent(event, hasNext); did throw a WorkflowExecutionException it would lead to a workflow failure. So it is more future proofing, it also may be possible with some user interceptor could throw a WorkflowExecutionException.

Copy link
Member

Choose a reason for hiding this comment

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

Works for me.

Copy link
Member

@cretz cretz left a comment

Choose a reason for hiding this comment

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

LGTM. I feel better knowing we are asserting exactly 1 and so we will make sure dupe fail counts don't creep in if/when we refactor to a common place.

@Quinn-With-Two-Ns Quinn-With-Two-Ns merged commit 3b26db7 into temporalio:master Jul 9, 2024
7 checks passed
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.

Java SDK is not reporting workflow_failures from the code path via the FailWorkflowExceptionTypes
2 participants