temporalio / temporalio/features

Do not set workflow completion until after all coroutines have settled in the task

Open
#481 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement
Dominant language
Go
Stars
32
Forks
28
Avg merge
1d 9h
Merged PRs (30d)
7

Description

Describe the problem

Today in core-based SDKs, we set workflow completion immediately upon workflow return and discard anything else that may happen on the same task. In Go/Java, we let the coroutines all complete even if they make commands and then set workflow completion after that. We should do the same in core-based SDKs.

In order to do this in a backwards-compatible way, we will need to leverage SDK flags. And in order to not have to put this flag on every workflow henceforth, SDKs will need to determine whether there are post-completion commands after the workflow returns.

An approach (EDIT: this is what was decided) (EDIT2: we decided not to go with this):

SDKs can choose one of the two options:

Option 1:

  • Change SDKs to, upon workflow function return, store the result and note the commands currently in buffer
  • Upon workflow completion and all coroutines settled:
    • If replaying and SDK flag not set, add the workflow completion command and discard any that came after
    • If not replaying and there are other commands before workflow completion, set the SDK flag and set those commands before setting workflow completion

Option 2:

  • When workflow complete command is in activation completion command set, do one of these three:
    • If SDK flag not set and replaying, do same thing as today (don't set flag, allow commands after completion to be removed)
    • If there are no non-query-complete commands after completion, do same thing (don't set flag)
    • Set the SDK flag and move the completion to the end (i.e. before any trailing query completions)
Another approach (EDIT: this was decided against) (EDIT 2: we decided to do this)
  • Send all post-complete commands to core instead of truncating like we do today
  • Let core decide to move workflow completion to the end + set flag or truncate post-completion commands if replaying and flag wasn't set
Describe the solution you'd like
Decision

We're going with the first approach above. And core doesn't need to do anything, it already allows flags.

Per-SDK Tickets

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the Decision section and the linked Core and per-SDK tickets to determine which SDK remains in scope. Done means post-completion commands are preserved after coroutines settle while replay remains backward-compatible through the SDK flag behavior described in the issue.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp, go, java, php, python, typescript
Domain
backend-api-design, distributed-systems, testing-qa
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.