Skip to content

Conversation

@bergundy
Copy link
Member

@bergundy bergundy commented Feb 4, 2022

In addition:

@bergundy bergundy requested review from cretz and lorensr February 4, 2022 08:13
workflowId,
});
const handleFromGet = client.getHandle(workflowId, undefined, {
firstExecutionRunId: handleFromThrowerStart.originalRunId,
Copy link
Contributor

Choose a reason for hiding this comment

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

when should we tell people to use this in docs?

Copy link
Member Author

Choose a reason for hiding this comment

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

When they want to make sure that they don't terminate / cancel a workflow if it's not part of a specific execution chain.

@bergundy bergundy enabled auto-merge (squash) February 9, 2022 20:03
@bergundy bergundy disabled auto-merge February 9, 2022 20:03
@bergundy bergundy enabled auto-merge (squash) February 9, 2022 20:03
@bergundy bergundy merged commit d54476f into main Feb 9, 2022
@bergundy bergundy deleted the no-run-id-in-start-handle branch February 9, 2022 20:25
@cretz
Copy link
Member

cretz commented Feb 10, 2022

Re temporalio/sdk-python#6 (comment), I think we might need to revisit this.

For handles returned by start and signal-with-start, we are allowing query, signal, cancel (for signal-with-start), and terminate (for signal-with-start) to occur on a completely different workflow. We should default to using the run ID for all of those I think.

// Server 1

const handle = await client.start(nuclearWorkflow,
  { args: ['do not detonate'], taskQueue: 'task-queue', workflowId: 'nuclear-workflow' });

// Meanwhile on server 2

const handle = await client.start(nuclearWorkflow,
  { args: ['detonate'], taskQueue: 'task-queue', workflowId: 'nuclear-workflow' });

// Back on server 1

if (await handle.query('should detonate')) {
  launch();
}

You just ended the world :-)

@lorensr
Copy link
Contributor

lorensr commented Feb 10, 2022

For startHandle.terminate(), we guard against terminating an out-of-chain workflow by including firstExecutionRunId, which the server checks before terminating?

Ideally (may require server change?) we could include firstExecutionRunId with query and signal? And when signal-with-starting, we either get back the firstExecutionRunId from the server, or we include applyIfChainIncludesRunId: runId with query/signal/cancel/terminate?

@cretz
Copy link
Member

cretz commented Feb 10, 2022

For startHandle.terminate(), we guard against terminating an out-of-chain workflow by including firstExecutionRunId, which the server checks before terminating?

Not good enough. Firstly that's only for terminate and cancel, not for query and signal. Secondly that doesn't apply to

Ideally (may require server change?) [...]

Yes, there are some changes on the server that can improve this. But as of now in master, the handle returned from start/signal-with-start query of this repo, signal, cancel (signal-with-start only), and terminate (signal-with-start only) can perform an action on a workflow started on another client that is unrelated except by its workflow ID. That is bad I think.

@bergundy
Copy link
Member Author

I'm not convinced you're right @cretz.
It really depends on the use case.
AFAIK, in a lot of cases users don't reuse the same workflow ID for different execution chains.

@bergundy
Copy link
Member Author

I think this change is a step in the right direction and we'll make it safer with server changes.

@cretz
Copy link
Member

cretz commented Feb 14, 2022

After discussion, while I disagree, the team has decided that for now it's ok to silently and accidentally signal, query, cancel, or terminate incorrect workflows until the server change is in place.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

5 participants