Skip to content

Conversation

@samanbarghi
Copy link
Contributor

@samanbarghi samanbarghi commented Mar 24, 2023

What changed?
Fail fast for query if the last workflow task has failed.

Why?
While workflow task is in failing state (due to non-deterministic error etc), the query to those workflow will fail anyway, and deliver query to the workflow will only waste resources to load history.
We should fail fast for query if we know the workflow task would fail.

How did you test it?
New functional test.

Potential risks
No risks.

Is hotfix candidate?
No.

@CLAassistant
Copy link

CLAassistant commented Mar 24, 2023

CLA assistant check
All committers have signed the CLA.

@samanbarghi samanbarghi force-pushed the bugfix/fail-query-fast-if-workflow-task-has-failed branch from 4e9acc3 to 61c0227 Compare March 24, 2023 18:45
@samanbarghi samanbarghi marked this pull request as ready for review March 24, 2023 18:58
@samanbarghi samanbarghi requested a review from a team as a code owner March 24, 2023 18:58
@alexshtin alexshtin changed the title Fail QueryWorkflow if last WorkflowTask failed Fail QueryWorkflow if last workflow task failed Mar 24, 2023
})

if err != nil {
s.Logger.Fatal("SetQueryHandler failed: " + err.Error())
Copy link
Member

Choose a reason for hiding this comment

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

I think Fatel may exit the process or fail the test?

if mutableState.GetExecutionInfo().WorkflowTaskAttempt > 1 {
// while workflow task is failing, the query to that workflow will also fail. Failing fast here to prevent wasting
// resources to load history for a query that will fail.
return nil, serviceerror.NewFailedPrecondition("Query has failed due to a failing workflow task")
Copy link
Member

Choose a reason for hiding this comment

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

Cannot query workflow due to Workflow Task in failed state.

s.True(workflowRun.GetRunID() != "")

// wait for workflow to fail
time.Sleep(time.Second * 5)
Copy link
Member

Choose a reason for hiding this comment

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

nit: do we have to wait for 5 sec? seems a bit long. I think workflow task attempt will be larger than 1 as soon as the first workflow task is failed.

Copy link
Member

@yycptt yycptt left a comment

Choose a reason for hiding this comment

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

Need this fix for 1.20.1 patch release.

@yiminc yiminc merged commit 3d6ac72 into temporalio:master Mar 25, 2023
yycptt added a commit that referenced this pull request Mar 25, 2023
* Fail QueryWorkflow if last WorkflowTask failed

* fix linter issues

* pr comments

---------

Co-authored-by: Saman Barghi <[email protected]>
Co-authored-by: Yichao Yang <[email protected]>
@samanbarghi samanbarghi deleted the bugfix/fail-query-fast-if-workflow-task-has-failed branch March 28, 2023 13:54
wxing1292 pushed a commit that referenced this pull request Apr 14, 2023
* Fail QueryWorkflow if last WorkflowTask failed

* fix linter issues

* pr comments

---------

Co-authored-by: Saman Barghi <[email protected]>
Co-authored-by: Yichao Yang <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants