Thang Kieu
11/25/2025, 1:28 AMMarvin
11/25/2025, 1:29 AMMarvin
11/25/2025, 1:39 AMprefect flow-run cancel <flow-run-id>
- Or, nudge them back to SCHEDULED via API so workers can pick them up again:
from prefect.client.orchestration import get_client
from prefect.client.schemas import StateCreate, StateType
import anyio
async def reschedule(run_id):
async with get_client() as client:
await client.set_flow_run_state(
run_id,
state=StateCreate(type=StateType.SCHEDULED)
)
anyio.run(reschedule, "<flow-run-id>")
- After changing a deployment’s concurrency limit, give workers a short window to re-poll. If you’re unblocking a backlog, a practical pattern is:
- Temporarily raise the limit to a large number (e.g., 10000), wait ~30–60s for AwaitingConcurrencySlot runs to re-evaluate, then adjust to your desired setting.
Prevention tips
- Prefer increasing the limit rather than toggling to “unlimited” when many runs are already in AwaitingConcurrencySlot; then tune it down after the queue clears.
- Keep workers running/healthy and watch for errors like “Aborted submission: Server returned a non‑pending state 'SCHEDULED'” (see #17452).
- Make sure there’s no separate work pool concurrency limit bottlenecking you.
Can you share a bit more so I can pinpoint the root cause?
- Prefect version (Cloud or self-hosted) and worker type (process, docker, k8s, ecs, push/pull).
- Whether the work pool has a concurrency limit or is paused.
- A sample flow-run ID stuck in PENDING and a snippet from the worker logs around the time it was claimed.Marvin
11/25/2025, 1:39 AMThang Kieu
11/25/2025, 2:08 AMThang Kieu
11/25/2025, 2:32 AMMarvin
11/25/2025, 2:32 AMMarvin
11/25/2025, 2:33 AMfrom prefect.client.orchestration import get_client
from prefect.client.schemas import StateCreate, StateType
import anyio
async def reschedule(run_id):
async with get_client() as client:
await client.set_flow_run_state(
run_id,
state=StateCreate(type=StateType.SCHEDULED)
)
anyio.run(reschedule, "<flow-run-id>")
Prevention and triage
- Ensure a healthy worker is running on the target work pool/queue (and the pool is not paused, and doesn’t have its own concurrency limit).
- If you changed the deployment concurrency limit from a small value to unlimited, briefly bump it to a large number (e.g., 10000) to clear the backlog, wait ~30–60s, then set your desired value.
- Consider an Automation: “Flow run stays in Pending for > N minutes” → “Set state: Scheduled” or “Cancel.” This recovers automatically from orphaned PENDING runs.
- If you see the “Aborted submission” message, check for:
- Deployment/work-pool concurrency rejections
- Work pool filters/labels mismatches
- Recent job variable changes (linked to #17452)
If you can share:
- Worker type (process/docker/k8s/ecs; push or pull), Cloud vs self-hosted
- Whether the work pool has a concurrency limit or is paused
- A sample flow run ID and the worker logs around the time it went PENDING
…I can pinpoint which of the two paths you’ve hit and recommend the safest fix for your setup.