Skip to content

[PR] fix(executor): prevent race condition in pause persistence #100

@Sebmono

Description

@Sebmono

ℹ This was originally a Pull Request (not recreated)
Original PR: simstudioai/sim#3088
Opened by: +h30s
Created at: 2026-01-30 20:42:38 UTC
Base branch: stagingHead branch: fix/pause-resume-race-condition-3081


Summary

Fixes a race condition where a resume request could fail with "Paused execution not found" if it arrived immediately after a workflow paused but before the paused state was fully persisted.

This PR ensures atomic persistence of paused executions so resume requests are handled reliably, even under high-throughput or near-simultaneous pause/resume scenarios.

Fixes #3081


Type of Change

  • Bug fix
  • New feature
  • Breaking change
  • Documentation
  • Other: ___________

Testing

How this was tested

  • Added unit tests covering the pause–resume race condition
  • Verified that database operations are executed within a transaction
  • Ensured queued resume requests are processed only after the transaction commits

What reviewers should focus on

  • Transaction wrapping in persistPauseResult
  • Correct sequencing of processQueuedResumes
  • Test coverage for concurrent pause/resume scenarios

Test Results

  • All unit tests passing (Vitest)
  • No TypeScript or linting errors
  • No behavioral changes outside pause/resume flow

Checklist

  • Code follows project style guidelines
  • Self-reviewed my changes
  • Tests added/updated and passing
  • No new warnings introduced
  • I confirm that I have read and agree to the terms outlined in the
    Contributor License Agreement (CLA)

Screenshots/Videos

Not applicable — backend-only change with no UI impact.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions