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

Partial revert #3731, fix errcheck, add comments #3787

Merged
merged 5 commits into from
Jan 20, 2023
Merged

Conversation

dnr
Copy link
Member

@dnr dnr commented Jan 7, 2023

What changed?

Why?
The logic in #3731 for errors from Cancel/TerminateWorkflow was wrong, it shouldn't return from a workflow.
The SideEffect errors can't happen by inspection since the types match, but in any case, we can safely panic since it's in a workflow context and the worst case is the workflow gets stuck.

How did you test it?
I wrote a unit test that simulated a failure from the CancelWorkflow local activity and tested it before and after. Unfortunately the workflow testing framework seems to be broken for local activity retries, so the test needs to have incorrect logic to match the bug in the framework. So it seems not worth including, though I can if we want.

Potential risks

Is hotfix candidate?

@dnr dnr requested a review from a team as a code owner January 7, 2023 04:21
if len(s.uuidBatch) == 0 {
if err := workflow.SideEffect(s.ctx, func(ctx workflow.Context) interface{} {
panicIfErr(workflow.SideEffect(s.ctx, func(ctx workflow.Context) interface{} {
Copy link
Contributor

Choose a reason for hiding this comment

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

To the worst, the worker will stuck in a crash loop?

Copy link
Member Author

Choose a reason for hiding this comment

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

It's inside a workflow task.. the sdk will catch it and the workflow will be blocked

@MichaelSnowden
Copy link
Contributor

The logic in #3731 for errors from Cancel/TerminateWorkflow was wrong, it shouldn't return from a workflow.

Out of curiosity, why can't we return errors like this from a workflow?

@dnr
Copy link
Member Author

dnr commented Jan 17, 2023

Out of curiosity, why can't we return errors like this from a workflow?

It'll end the workflow. It's supposed to be a long-running workflow

@@ -690,7 +676,8 @@ func (s *scheduler) addStart(nominalTime, actualTime time.Time, overlapPolicy en
}

// processBuffer should return true if there might be more work to do right now.
func (s *scheduler) processBuffer() (bool, error) {
//nolint:revive
Copy link
Member

Choose a reason for hiding this comment

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

What does revive complain about here?

Copy link
Member Author

Choose a reason for hiding this comment

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

Cyclomatic complexity (even though this diff reduces it). I'm dubious of that metric. I'm not claiming this function is easy to understand, but all my attempts at simplifying it seemed to make it worse (required helper functions with 6+ args for example). I've found that true in general: splitting up a large function into smaller ones can be harder to understand overall because the pieces don't make sense out of context and you end up passing most of the local vars anyway. So it's okay as a guideline but a hard cutoff doesn't make sense.

Copy link
Member Author

Choose a reason for hiding this comment

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

Anyone is welcome to take a try at simplifying this, though

@dnr dnr merged commit 82c958d into temporalio:master Jan 20, 2023
@dnr dnr deleted the sched35 branch January 20, 2023 20:36
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.

4 participants