.NET API
ISingletonLeaseStore
Tracon.Abstractions.dllThe lease store that keeps a named job running on a single instance across the cluster.
public interface ISingletonLeaseStoreRemarks
Section titled “Remarks”Single-executor election uses it to coordinate background jobs such as MCP discovery and model health probing, which must not repeat on several replicas. The lease is a table, not a session lock: it behaves the same way on all three SQL providers (PostgreSQL, SQL Server, SQLite), and SQLite has no session lock equivalent.
While SingletonExecutionOptions.Enabled is false (the default) this store is never called — a single-instance setup pays no extra database round trip.
DI lifetime — singleton. Registered as a singleton with
TryAdd; a consumer’s own registration wins.
Tenant behavior — TENANT-INDEPENDENT. A lease name identifies a
protected JOB ("mcp-discovery", a health-probe job id), not a tenant; leases
are not scoped by tenant at all.
Guarantee limit: this lease is eventually correct, not strictly
exclusive. It gives no hard mutual-exclusion guarantee the way a
database advisory lock or session lock would — this is deliberate (SQLite has no
session-lock equivalent, so the lease had to be a plain table row instead). A lease
owner that freezes past its own duration without releasing it — a GC pause,
thread starvation, or a network partition that cuts it off from the store — leaves a
narrow split-brain window: ISingletonLeaseStore.TryAcquireAsync lets a SECOND instance take
the same lease once it expires, while the frozen first owner may resume and believe
it still holds it, until its own next ISingletonLeaseStore.RenewAsync call (correctly)
reports it lost the lease. A consumer whose protected job is not idempotent under a
brief overlap must not rely on this store alone.
Methods
Section titled “Methods”ReleaseAsync(string, string, CancellationToken)
Section titled “ ReleaseAsync(string, string, CancellationToken)”Releases the lease. It does nothing when the caller is not the owner.
ValueTask ReleaseAsync(string name, string ownerId, CancellationToken cancellationToken = default)Parameters
Section titled “Parameters”name string
The name of the lease.
ownerId string
The id of the instance that claims to hold the lease.
cancellationToken CancellationToken
The cancellation token.
Returns
Section titled “Returns”A task that completes when the work is done.
RenewAsync(string, string, TimeSpan, CancellationToken)
Section titled “ RenewAsync(string, string, TimeSpan, CancellationToken)”Extends the lease that is held. It returns false when the lease has moved to someone else — the caller MUST then drop the job.
ValueTask<bool> RenewAsync(string name, string ownerId, TimeSpan duration, CancellationToken cancellationToken = default)Parameters
Section titled “Parameters”name string
The name of the lease.
ownerId string
The id of the instance that claims to hold the lease.
duration TimeSpan
The new lease duration.
cancellationToken CancellationToken
The cancellation token.
Returns
Section titled “Returns”true when the renewal succeeded.
TryAcquireAsync(string, string, TimeSpan, CancellationToken)
Section titled “ TryAcquireAsync(string, string, TimeSpan, CancellationToken)”Tries to take the lease. It returns false when someone else holds the lease and it has not expired.
ValueTask<bool> TryAcquireAsync(string name, string ownerId, TimeSpan duration, CancellationToken cancellationToken = default)Parameters
Section titled “Parameters”name string
The name of the lease (the id of the protected job).
ownerId string
The id of this instance.
duration TimeSpan
How long the lease stays valid.
cancellationToken CancellationToken
The cancellation token.
Returns
Section titled “Returns”true when the lease was taken.