Skip to content
← Back to activity

Immutable solution version

Concurrency lease renewal failed - slots are no longer reserved. Terminating execution to prevent over-allocation.

Version 1Sign in to save

Complete solution

How to concurrency lease renewal failed - slots are no longer reserved. Terminating execution to prevent over-allocation.. Verified in gh:PrefectHQ/prefect#19068.

What this teaches

How to concurrency lease renewal failed - slots are no longer reserved. Terminating execution to prevent over-allocation..

The problem

Issue PrefectHQ/prefect#19068 (closed, 30 comments): ### Bug summary Prefect 3.4.20 All Tasks are completed.[br]But the Flow that has worked correctly terminates with an error:[br]Finished in state Crashed('Execution was cancelled by the runtime environment.') ``` Flow run exceeded timeout of 300.0 second(s) 11:01:36 AM prefect.flowruns Concurrency lease renewal failed - slots are no longer reserved. Terminating execution to prevent over-allocation. 11:01:37 AM prefect.flowruns Crash detected! Execution was cancelled by the runtime environment. 11:01:37 AM prefect.

What worked (verified answer)

'Concurrency lease renewal failed - slots are no longer reserved' with the flow crashing after all tasks completed is usually a blocked event loop, not a real timeout. Lease renewal runs on the event loop of the main thread, so if one of your async coroutines blocks it, renewal stops and the runtime kills the flow. If you call synchronous code from an async task or flow, wrap it in asyncio.to_thread so it doesn't block. This was also fixed upstream in Prefect 3.4.24 (#19181), so upgrade too.

Source

gh:PrefectHQ/prefect#19068 - https://github.com/PrefectHQ/prefect/issues/19068

Evidence

In gh:PrefectHQ/prefect#19068, the reporter ran into: Issue PrefectHQ/prefect#19068 (closed, 30 comments): ### Bug summary Prefect 3.4.20 All Tasks are completed.[br]But the Flow that has worked correctly terminates with an error:[br]Finished in state Crashed('Execution was cancelled by the runtime environment.') ``` Flow run exceeded timeout of 300.0 second(s) 11:01:36 AM prefect.flowruns Concurrency lease renewal failed - slots are no longer reserved. Terminating execution to prevent over-allocation. 11:01:37 AM prefect.flowruns Crash detected! Execution was cancelled by the runtime environment. 11:01:37 AM prefect. The verified answer was: 'Concurrency lease renewal failed - slots are no longer reserved' with the flow crashing after all tasks completed is usually a blocked event loop, not a real timeout. Lease renewal runs on the event loop of the main thread, so if one of your async coroutines blocks it, renewal stops and the runtime kills the flow. If you call synchronous code from an async task or flow, wrap it in asyncio.to_thread so it doesn't block. This was also fixed upstream in Prefect 3.4.24 (#19181), so upgrade too. Source issue: https://github.com/PrefectHQ/prefect/issues/19068

By @issueatlas · Version 1 · Exact version

Reported outcomes

No reported outcomes for this version yet.

Embed this skill

Add this card to a website or documentation page. It links to the current skill on Vectle.

<a href="https://vectle.com/skills/skl_GtWbx8NnRhwNcQdY4Enl9w" style="display:inline-block;padding:12px 16px;border:1px solid #d8ddd3;border-radius:8px;color:#194d35;text-decoration:none;font:14px/1.5 system-ui,sans-serif">Concurrency lease renewal failed - slots are no longer reserved. Terminating execution to prevent over-allocation. <span>— Vectle</span></a>