arbiter-core-0.1.0.0
arbiter-core
Safe HaskellNone
LanguageGHC2024

Arbiter.Core.Sql.Concurrency

Description

Concurrency SQL templates.

Synopsis

Documentation

Source #updateConcurrencyPolicyOverrideSQL :: SchemaName -> Maybe (Maybe Int32) -> Text -> Query ()

Set a pool's operator override limit. Nothing leaves it untouched. Just v writes v (a null clears the override back to the default).

Source #liveConcurrencyKeysUnion :: SchemaName -> [TableName] -> Text

Every concurrency_key held by a live job, unioned across the queue tables.

Source #lockDeadConcurrencyKeysSQL :: SchemaName -> [TableName] -> Query Text

Lock count rows with no live job, in the triggers' key order. Returns the locked keys.

Source #pruneLockedConcurrencyKeysSQL :: SchemaName -> [TableName] -> [Text] -> Query ()

Delete the passed locked keys that are still dead under a fresh snapshot.

Source #tryLockDeadConcurrencyAdvisorySQL :: [Text] -> Query Text

Try an exclusive per-key advisory lock over the dead keys, pairing the insert trigger's shared lock. Never waits. Returns the keys acquired.

Source #lockConcurrencyCountsSQL :: SchemaName -> Query Text

Lock every count row in key order.

Source #reconcileConcurrencyCountsSQL :: SchemaName -> [TableName] -> [Text] -> Query Int64

Recount in_flight for the passed locked keys and seed a row for a live key that has none. Writes the rows the caller locked and fresh inserts. Run after lockConcurrencyCountsSQL in one transaction. Returns the number repaired.

Source #listConcurrencyPoliciesSQL :: SchemaName -> Query ConcurrencyPolicyView

List every concurrency pool with its default/override limit and live key and in-flight aggregates.

Source #listConcurrencyKeysSQL :: SchemaName -> Text -> Int64 -> Int64 -> Query ConcurrencyKeyView

List a prefix's keys with effective cap and in-flight fill fraction, paginated.

Source #concurrencyHasAnyKeySQL :: SchemaName -> Query Bool

Whether any concurrency key exists.

Source #concurrencyCountsStaleSQL :: SchemaName -> [TableName] -> Query Bool

Whether a crash truncated the count table (a live keyed job has no count row).