conductor icon indicating copy to clipboard operation
conductor copied to clipboard

User defined workflow ID

Open mohelsaka opened this issue 7 years ago • 1 comments

Hello,

Is there a way to ensure that workflow is running at most once for some particular payload? So that if POST /workflow/{name} was called twice at the same time with the same workflow input, only one call will be accepted and the others will be rejected (or do nothing).

I thought of three ways to solve this problem:

  1. From the client side. Store the workflow ID in some storage and check this storage before calling conductor server to start the workflow.
  2. In the workflow itself, add a task that queries conductor search API with the payload and checks if there are any running WFs before or not, and if there are any, fail the WF (It can be done using HTTP System Task, maybe).
  3. Having user-defined unique workflow id, something similar to what SWF is doing with workflowid, details are here.

I believe the 3rd solution is the cleanest, as it's less overhead on the client (unlike the 1st approach) and less irrelevant tasks in the workflow (unlike the 2nd approach).

If you have similar use problem, can you please share how you solve it?

Also if you think that the 3rd approach makes sense then I'm up to pushing a PR for it.

Thanks!

mohelsaka avatar Feb 12 '19 17:02 mohelsaka

@mohelsaka Currently, conductor does not provide a construct to ensure that only one workflow is currently running for a particular payload. However, as you pointed out, this can be achieved by one of the ways that you have suggested.

  1. This involves the client maintaining a storage for workflow ids and ensuring sync with the conductor server.
  2. This is not a reliable model, since the search API uses ES which can have a latency depending on the indexing of the data in the cluster, resulting in stale results.
  3. I agree that this is the cleanest solution.

Please feel free to submit a PR for the same and we will be happy to review and merge it. Please ensure that the user-defined workflow id is a UUID and that there is no contention with the workflow ids that the conductor server mints.

apanicker-nflx avatar Feb 15 '19 18:02 apanicker-nflx