Skip to content

Scheduler shutdown can leave startup recovery running after stop returns #3397

Description

@ohdearquant

_run_startup_recovery() creates a separate passes task and waits on it through asyncio.shield(). In the stop path at lionagi/studio/scheduler/engine.py:744-747, it calls passes.cancel() and immediately re-raises without awaiting the task termination. If a recovery operation performs cancellation cleanup or otherwise delays cancellation, the outer tick task finishes and stop() continues to close the scheduler state service while passes is still using it. This leaves a background recovery task racing shutdown and can produce post-shutdown database errors or incomplete recovery.

Drain the passes task after requesting cancellation before allowing stop() to continue closing the state service; preserve the non-stop path shielding so ordinary stray cancels still let recovery finish.

Introduced by PR #3381. Relevant code: engine.py#L744-L747.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    regression-watchConfirmed regressions in merged changes

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions