arbiter-core-0.1.0.0
arbiter-core
Safe HaskellNone
LanguageGHC2024

Arbiter.Core.Sql.Tree

Description

Internal to the arbiter packages. Not covered by the PVP.

Tree SQL templates.

Synopsis

Documentation

pauseChildrenSQL :: SchemaName -> TableName -> Int64 -> Query ()Source #

Suspend every unsuspended visible job in a parent's subtree, lapsed leases included. Jobs with a future visibility (delayed, backoff, throttled, leased) are skipped.

resumeChildrenSQL :: SchemaName -> TableName -> Int64 -> Query ()Source #

Resume the suspended jobs in a parent's subtree. A finalizer with children still in the queue stays suspended.

lockedByIdsCte :: Text -> [Int64] -> Query ()Source #

CTE binding locked to the ids named, locked in descending id order. The statement carries id IN (SELECT id FROM locked) to keep the CTE.

childDescendantsCte :: Text -> Int64 -> Query ()Source #

descendantsFromCte seeded from a parent's children, excluding the parent itself.

wakeParentCte :: Text -> Text -> Query ()Source #

CTE binding wake_parent to the suspended parent of source's rows, resumed when no other child remains.

lockJobTreesSQL :: SchemaName -> TableName -> [Int64] -> Query Int64Source #

Lock the named jobs and all their descendants, several trees in one pass. Locks rows in descending id order. Then lock the group summaries of the rows and their parents.

lockJobTreesFromRootSQL :: SchemaName -> TableName -> [Int64] -> Query Int64Source #

Extend lockJobTreesSQL to the complete tree of each named job. This locks all rows that tree cancellation can delete. The named identifiers also start the downward walk. An orphan locks its subtree.

cancelJobCascadeSQL :: SchemaName -> TableName -> Int64 -> Query Int64Source #

Cancel a job and all its descendants recursively. Locks rows in descending id order. Returns the ids deleted.

forceCancelJobSQL :: SchemaName -> TableName -> Int64 -> Query Int64Source #

Force-cancel a job subtree. Flags still-live claimed jobs and bumps their claim token once, deletes the rest, and NOTIFYs every claimed job affected.

cancelTokenBump :: Int64Source #

The amount that a force-cancel flag adds to the claim token.

deleteLapsedCancelledJobsSQL :: SchemaName -> TableName -> [Int64] -> Query (Int64, Maybe Int64)Source #

Delete the force-cancel-flagged jobs that have no live lease.

deleteHeldCancelledJobsSQL :: SchemaName -> TableName -> UUID -> [(Int64, Int64)] -> Query (Int64, Maybe Int64)Source #

Delete the force-cancel-flagged jobs that owner holds. Each pair is a job id and the claim token that its claim returned.

selectCancelledReapableJobsSQL :: SchemaName -> TableName -> Int -> Query Int64Source #

Flagged jobs whose lease has lapsed. The reaper deletes them and resumes their parents.

cancelJobTreeSQL :: SchemaName -> TableName -> Int64 -> Query Int64Source #

Cancel an entire job tree by walking up from any node to the root, then cascade-deleting everything from the root down. Locks rows in descending id order. Deletes nothing for an orphan. Returns the ids deleted.

tryWakeAncestorSQL :: SchemaName -> TableName -> Int64 -> Query ()Source #

Resume a suspended parent for its completion round, once no child of it is left in the main queue.

treeRollupIdsSQL :: SchemaName -> TableName -> Int64 -> Query Int64Source #

Rollup finalizer ids in a job's subtree, the job itself included. Read before a DLQ move.

suspendJobSQL :: SchemaName -> TableName -> Int64 -> Query ()Source #

Suspend a job, making it unclaimable. Refuses an in-flight job.

resumeJobSQL :: SchemaName -> TableName -> Int64 -> Query ()Source #

Resume a suspended job. Refuses a finalizer with children still in the main queue. A child in the DLQ is terminal. The finalizer reads its error through readChildResultsSQL and decides for itself.

beginSpawnSQL :: SchemaName -> TableName -> Int64 -> Int64 -> Query ()Source #

Mark a claimed, childless job as a rollup finalizer, matched on the claim token. The ack's suspend branch refunds the attempt.

spawnedAlreadySQL :: SchemaName -> TableName -> Int64 -> Int64 -> Query BoolSource #

Whether a job has already spawned a round under the given claim token.

rollupIdsSQL :: SchemaName -> TableName -> [Int64] -> Query Int64Source #

Which of the given ids carry a rollup finalizer's parent_state.

getParentIdsSQL :: SchemaName -> TableName -> [Int64] -> Query (Maybe Int64)Source #

Fetch the parent ids of several jobs.

advisoryXactLockManySQL :: Text -> [Int64] -> Query (Maybe Text)Source #

Take the transaction-scoped advisory locks keyed by a schema.table string and the ids named, ascending, in one round trip.

jobExistsSQL :: SchemaName -> TableName -> Int64 -> Query BoolSource #

Check whether a job with the given id exists.

insertResultSQL :: SchemaName -> TableName -> Int64 -> Int64 -> Value -> Query ()Source #

Insert a child's result into the results table.

insertResultsBatchSQL :: SchemaName -> TableName -> [Int64] -> [Int64] -> [Value] -> Query ()Source #

insertResultSQL for several children in one statement.

getResultsByParentSQL :: SchemaName -> TableName -> Int64 -> Query (Int64, Value)Source #

Get all child results for a parent from the results table.

deleteResultsByParentSQL :: SchemaName -> TableName -> Int64 -> Query ()Source #

Drop a parent's stored child results.

detachDLQChildrenSQL :: SchemaName -> TableName -> Int64 -> Query ()Source #

Detach a parent's DLQ children.

getDLQChildErrorsByParentSQL :: SchemaName -> TableName -> Int64 -> Query (Int64, Maybe Text)Source #

Get DLQ child errors for a parent, one (job_id, last_error) row per DLQ'd child.

persistParentStateSQL :: SchemaName -> TableName -> Value -> Int64 -> Query ()Source #

Snapshot child results into parent_state before a DLQ move.

getParentStateSnapshotSQL :: SchemaName -> TableName -> Int64 -> Query (Maybe Value)Source #

Read a job's raw parent_state snapshot.

readChildResultsSQL :: SchemaName -> TableName -> Int64 -> Query (Text, Maybe Int64, Maybe Value, Maybe Text, Maybe Int64)Source #

A rollup finalizer's child results, DLQ child errors, and parent_state snapshot in one query, tagged r, e and s respectively.