Skip to content

[Bug] Sliding window example has a race #279

@antlai-temporal

Description

@antlai-temporal

Describe the bug

As described in https://community.temporal.io/t/implement-sliding-window-batching-in-python/15959/2
the code https://github.com/temporalio/samples-python/blob/main/batch_sliding_window/sliding_window_workflow.py#L111-L120

            child_handle = await workflow.start_child_workflow(
                RecordProcessorWorkflow.run,
                record,
                id=child_id,
                id_reuse_policy=WorkflowIDReusePolicy.ALLOW_DUPLICATE,
                parent_close_policy=workflow.ParentClosePolicy.ABANDON,
            )

            self.children_started_by_this_run.append(child_handle)
            self.current_records.add(record.id)

completes the workflow task with the await, and it could happen that the started child finishes, and send a completion signal, before the record.id is added to self.current_records. Then, the signal handler will ignore
the notification...

The proposed solution is to add the record.id before starting the child workflow, as described in the link.

Minimal Reproduction

make the child workflows finish immediately without sleep...

Environment/Versions

  • OS and processor: [e.g. M1 Mac, x86 Windows, Linux]
  • Temporal Version: [e.g. 1.14.0?] and/or SDK version
  • Are you using Docker or Kubernetes or building Temporal from source?

Additional context

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions