8000 [Bug] Updates conflict with replay · Issue #848 · temporalio/sdk-python · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

[Bug] Updates conflict with replay #848

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

Open
ndtretyak opened this issue Apr 24, 2025 · 2 comments
Open

[Bug] Updates conflict with replay #848

ndtretyak opened this issue Apr 24, 2025 · 2 comments
Labels
bug Something isn't working

Comments

@ndtretyak
Copy link
Contributor
ndtretyak commented Apr 24, 2025

What are you really trying to do?

I'm using updates to allow the workflow to proceed to the next step.

Describe the bug

If an update occurs when the workflow execution is not cached on the worker, the update is effectively "lost", and I need to issue another update for it to be applied.

Minimal Reproduction

  1. Start the worker

  2. Start the workflow

    temporal workflow start --task-queue my-task-queue --type Workflow --workflow-id test --id-reuse-policy TerminateIfRunning
    
  3. Restart the worker

  4. Execute the update

    temporal workflow update execute --workflow-id test --name go
    
  5. Observe that the activity has not been scheduled during the update handling. Additionally, there are some debug prints in the workflow code that may help.

import asyncio
import concurrent.futures
import datetime

from temporalio import activity
from temporalio import workflow
from temporalio.client import Client
from temporalio.worker import Worker


@activity.defn
async def job() -> None:
    activity.logger.info("Activity started")


@workflow.defn(sandboxed=False)
class Workflow:
    def _set_can_run(self, value: bool, comment: str) -> None:
        print("Setting can_run to:", value, "comment:", comment)
        self.can_run = value

    @workflow.update
    def go(self) -> None:
        self._set_can_run(True, "update")

    @workflow.run
    async def run(self) -> None:
        self._set_can_run(True, "workflow start")

        def wait_condition() -> bool:
            print("Checking condition. result:", self.can_run)
            return self.can_run

        while True:
            await workflow.wait_condition(wait_condition)
            await workflow.execute_activity(job, start_to_close_timeout=datetime.timedelta(seconds=5))
            self._set_can_run(False, "activity completed")


async def main():
    client = await Client.connect("localhost:7233")

    with concurrent.futures.ThreadPoolExecutor(max_workers=100) as activity_executor:
        worker = Worker(
            client,
            task_queue="my-task-queue",
            workflows=[Workflow],
          activities=[job],
          activity_executor=activity_executor,
        )
    await worker.run()


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

Environment/Versions

  • Temporal Version: 1.27.1
  • SDK Version: 1.11.0
@ndtretyak ndtretyak added the bug Something isn't working label Apr 24, 2025
@dandavison
Copy link
Contributor

Thanks for this @ndtretyak. It does look like a bug; we're looking into it.

@Sushisource
Copy link
Member

Fixed in Core in temporalio/sdk-core#910 - Python will need Core update & release

< 553E input type="hidden" data-csrf="true" name="authenticity_token" value="XYuIRQuNX41LtdrBXDciU6pijYNfBEwQHMv2t2n1JYoZXG/wPC/Fj6xx0WDHoATraPZNqPCm3I2nOlYkGPlgPg==" />

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants
0