temporalio / temporalio/cli

[Bug] batch reset on completed workflows sometimes results in terminated workflows

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

Nobody has claimed this yet.

bug
Dominant language
Go
Stars
379
Forks
103
Avg merge
2d 11h
Merged PRs (30d)
23

Description

Describe the bug

When performing a batch reset on completed workflows, sometimes they end up in terminated state.

I have not properly investigated yet, but it felt incorrect. It may not be specific to CLI, but I want to have a ticket open for it.

Minimal Reproduction

Create a workflow with

Python workflow
import asyncio
from datetime import timedelta

from temporalio import activity, workflow

from dan.utils.client import start_workflow


@activity.defn
async def my_activity(name: str) -> str:
    return f"Hello, {name}!"


activities = [my_activity]


@workflow.defn
class Workflow:
    def __init__(self):
        self.received_signal = False
        self.received_update = False

    @workflow.run
    async def run(self) -> str:
        await workflow.wait_condition(
            lambda: self.received_signal and self.received_update
        )
        return "workflow-result"

    @workflow.signal
    def my_signal(self) -> None:
        self.received_signal = True

    @workflow.update
    async def my_update(self) -> None:
        await workflow.execute_activity(
            my_activity, "update", start_to_close_timeout=timedelta(seconds=10)
        )
        self.received_update = True


async def main():
    wf_handle = await start_workflow(Workflow.run)
    print("workflow handle:", wf_handle)
    await wf_handle.signal(Workflow.my_signal)
    await wf_handle.execute_update(Workflow.my_update)
    print("workflow result:", await wf_handle.result())


if __name__ == "__main__":
    asyncio.run(main())

Then issue this command (it can be repeated; the number of workflows grows exponentially in doing so)

temporal workflow reset --type FirstWorkflowTask --reason 'testing' --query "WorkflowType STARTS_WITH ''"

Sooner or later, one of the workflows will be in terminated state, with the UI saying terminated by "history resetter".

Contributor guide

Open the contributing guide

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 by reproducing the issue with the Python workflow and the temporal workflow reset --type FirstWorkflowTask --reason 'testing' --query "WorkflowType STARTS_WITH ''" command. Inspect the reset behavior when completed workflows are processed and verify the history resetter does not leave any workflow in a terminated state.】【。

Written by the indexing model from the issue text.

Assessment

Tech stack
go
Domain
cli
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.