Anish Moorjani
03/16/2026, 11:17 PMMarvin
03/16/2026, 11:17 PMMarvin
03/16/2026, 11:24 PMHTTPStatusError 410 and connection errors in worker logs.
- Avoid deleting/resetting the relevant concurrency limit while runs are active.
- If using async flows, avoid long blocking calls in the event loop; offload to threads/processes or use non-blocking helpers.
- For Kubernetes, consider PodDisruptionBudgets, graceful termination, and resource requests that keep the runtime from being paused/starved.
- Keep an eye on Cloud status for incidents: Prefect Cloud status.
- Tuning
- For user-managed concurrency contexts (not deployment concurrency), you can increase the lease duration so there’s more tolerance for transient blips:
from prefect.concurrency.sync import concurrency
with concurrency("dbt-prod", lease_duration=900, strict=True):
run_dbt_build() # your dbt step
- lease_duration defaults to 300s; try 600–1800s for long dbt operations.
- If you prefer the run to continue even if the lease can’t be renewed (accepting the risk of temporarily exceeding the limit), set strict=False.
- Note: Deployment-level concurrency always operates in strict mode and uses a fixed lease strategy; if you need custom lease durations for long-running dbt steps, consider moving the constraint to an explicit concurrency(...) block around the critical section instead of using deployment concurrency.
What I’d check next
- Are you using deployment-level concurrency limits in the Prefect Cloud UI for these flows? If yes, the strict cancellation explains the behavior.
- Did anyone reset/delete the relevant concurrency limit around the failure timestamps?
- What worker type/environment are you using (Kubernetes, Docker, VM)? Any restarts or pauses recorded at those times?
- Rough duration of your dbt runs, and how frequently the failures occur.
- A couple of failed flow run IDs and timestamps so we can correlate with logs.Marvin
03/16/2026, 11:24 PMAnish Moorjani
03/16/2026, 11:26 PMMarvin
03/16/2026, 11:26 PMMarvin
03/16/2026, 11:30 PMfrom prefect import flow
from prefect.concurrency.sync import concurrency
@flow
def dbt_flow_ca():
# Create a concurrency limit named "dbt-internal-ca" (limit=1) in the UI first
with concurrency("dbt-internal-ca", occupy=1, lease_duration=1800, strict=False):
run_dbt_build() # your dbt invocation
- Trade-off: stronger resiliency, but during a transient failure the lease may lapse and a second run could start if something else acquires the slot. In practice this is rare if outages are brief and lease_duration is generous.
C) Gate starts with per-region work pools (no mid-run lease to renew)
- Create a work pool per region and set its pool-level concurrency to 1; point the region’s deployments to the region’s pool.
- This enforces “only one run can start per region” at the scheduling/worker layer and does not rely on an in-run lease — so you won’t see mid-run cancellations from lease renewal.Marvin
03/16/2026, 11:30 PMlease_duration (e.g., 900–1800s for long runs) and strict to control behavior on renewal failure.
- Concurrency concepts: docs: Concurrency limits
Recommended path for your requirement
- If you want zero tolerance for overlap and are okay retrying on rare blips:
- Keep deployment-level concurrency per region (what you have).
- Add an Automation to retry on Crashed with a small backoff (e.g., up to 1–2 retries).
- Harden the runtime: check for pod/VM restarts, ensure stable egress to Cloud, avoid limit resets.
- If you want “never crash mid-run” and can accept a tiny risk of temporary over-enforcement loss:
- Remove deployment-level concurrency and guard runs with a flow-level concurrency context per region, using a long lease_duration (e.g., 1800s) and strict=False as shown above.
- If you prefer to enforce “one-at-a-time per region” without any in-run lease at all:
- Create one managed work pool per region and set each pool’s concurrency to 1, then point each region’s deployment at its region’s pool.
If you can share a couple of failing flow run IDs and timestamps, I can help you correlate with worker restarts or network logs to pinpoint whether these were expiry due to missed renewals vs. a limit reset.
Useful links
- Concurrency limits: docs: Concurrency limits
- Deployment concurrency: docs: Deployment concurrency
- Lease renew endpoint: API: renew concurrency lease
- Automations (for retries): docs: Automations
- Cloud status: Prefect Cloud status