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

Fix panic on starting child workflows with duplicate IDs #999

Merged
merged 3 commits into from
Jan 6, 2023

Conversation

Sushisource
Copy link
Member

What was changed

Fix this panic. See the added docstring in the PR for more.

Why?

Panic bad, yo.

Checklist

  1. Closes Panic: Error adding duplicate command on duplicated child workflow #947

  2. How was this tested:
    Added integ test, existing tests.

  3. Any docs updates needed?

@Sushisource Sushisource requested a review from a team as a code owner January 5, 2023 22:59
Comment on lines +1269 to +1270
if h.commands[command.getID()] != nil {
return nil, &childWorkflowExistsWithId{id: attributes.WorkflowId}
Copy link
Member Author

Choose a reason for hiding this comment

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

I can't say I love this, but as is often the case in the Go SDK it seemed like the least offensive of some unfortunate options.

return err
}
err = workflow.ExecuteChildWorkflow(childCtx, w.childWorkflowWaitOnSignal).Get(ctx, nil)
if _, ok := err.(*internal.ChildWorkflowExecutionAlreadyStartedError); !ok {
Copy link
Contributor

Choose a reason for hiding this comment

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

Shouldn't we expose this error outside of internal?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah, so, it is one of the many things that's aliased. I can't refer to the temporal version of it here b/c circular import. It's aliased here:

ChildWorkflowExecutionAlreadyStartedError = internal.ChildWorkflowExecutionAlreadyStartedError

I don't track the whole aliasing stuff so if I need to somehow return it differently I'm all ears.

Copy link
Contributor

Choose a reason for hiding this comment

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

How come other errors can be used from temporal https://github.com/temporalio/sdk-go/blob/master/test/workflow_test.go#L220 but this one can't?

Copy link
Member Author

Choose a reason for hiding this comment

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

Hahah, derp. I didn't realize this comment was on the test file. Fixed.


// Error returned when a child workflow with the same id already exists and hasn't completed
// and been removed from internal state.
childWorkflowExistsWithId struct {
Copy link
Contributor

Choose a reason for hiding this comment

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

Why create a new error instead of using ChildWorkflowExecutionAlreadyStartedError?

Copy link
Member Author

Choose a reason for hiding this comment

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

That's a proto - so it doesn't impl the Error interface and feels icky to use in this place

@Quinn-With-Two-Ns
Copy link
Contributor

Once we have sdk versioning could we align the go sdk with the other sdks since we will be able to make a backwards incompatible change like changing the ID

@Sushisource
Copy link
Member Author

Once we have sdk versioning could we align the go sdk with the other sdks since we will be able to make a backwards incompatible change like changing the ID

At that point we'll want to just move to be on top of Core. I think we should invest the minimum amount of time possible into the state machine internals here.

Copy link
Member

@bergundy bergundy left a comment

Choose a reason for hiding this comment

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

I agree this is better than panicking.
We'll change to reach the server if we ever use Core to power this SDK.

@Sushisource Sushisource merged commit f965f94 into temporalio:master Jan 6, 2023
@Sushisource Sushisource deleted the no-panic-dupe-child branch January 6, 2023 03:12
@cretz
Copy link
Member

cretz commented Jan 6, 2023

we will be able to make a backwards incompatible change like changing the ID

Not sure that's a backwards incompatible change. The ID is only internal for SDK use IIRC.

Also note, this still occurs with activity ID. We should probably fix that too.

Also, technically, one should be allowed to try to start a child workflow of an ID already started but maybe not finished from the same workflow, but I think this is fine for now.

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.

Panic: Error adding duplicate command on duplicated child workflow
4 participants