Version v0.1 · dotnet
Lease Configuration
Configure lease duration and reclaim behavior for safe distributed execution.
Lease Configuration
Leases ensure only one worker actively owns a run at a time under normal operation.
Lease settings balance two things:
- fast recovery when workers die
- avoiding premature reclaim for legitimate long-running jobs
Key option
LeaseDuration/LeaseDurationSeconds: lease time-to-live for claimed runs.
DurableStack extends leases during execution via heartbeat.
Example
builder.Services.AddDurableStackPostgres(connectionString, options =>
{
options.LeaseDurationSeconds = 30;
});
How it behaves
- Worker claims run and receives lease ownership.
- Heartbeat extends lease while job is running.
- If heartbeat stops, lease expires and run can be reclaimed.
Tuning guidance
- Set lease duration above normal execution time for routine jobs.
- For mixed workloads, size lease around common-path jobs and keep handlers idempotent.
- Validate reclaim behavior in staging by killing workers during execution.
Warning signs
- Frequent unexpected retries for normally healthy jobs (lease may be too short).
- Slow recovery after worker crashes (lease may be too long).