arbiter-core-0.1.0.0
arbiter-core
Safe HaskellNone
LanguageGHC2024

Arbiter.Core.Job.Schema.Groups

Description

Schema for the per-queue group summary table and the statement-level triggers that maintain it. The summary carries each group's head, counts and visibility deadlines. The claim ranks groups from it.

Synopsis

Grouped Job Indexes

Source #createJobQueueGroupKeyIndexSQL :: Text -> Text -> Text

Partial index over (group_key, priority, id), read by the claim's LATERAL subqueries and by the maintenance triggers recomputing a group's minima and in_flight_until.

Source #createJobQueueGroupRetriedIndexSQL :: Text -> Text -> Text

Partial index over (group_key, attempts DESC, priority, id) for retried rows, read by the claim's group head gate. Retried rows rank ahead of the rest. The gate merges this run with the (group_key, priority, id) scan.

Source #createJobQueueGroupedDueIndexSQL :: Text -> Text -> Text

Scheduled grouped jobs by due time. Group maintenance uses this index to replace next_due with one point lookup.

Source #createJobQueueGroupInFlightIndexSQL :: Text -> Text -> Text

Possible in-flight grouped jobs by descending lease deadline. The query applies the time-dependent part of the predicate at runtime.

Groups Table SQL

Source #createGroupsTableSQL :: Text -> Text -> Text

Create a queue's groups table, one summary row per group_key carrying the group's precomputed minima, counts and in_flight_until. Maintained by the statement-level AFTER triggers in createGroupsTriggerFunctionsSQL.

Source #migrateGroupsReadyRankingSQL :: Text -> Text -> Text

Add ready_count and next_due to the groups summary, make the ranking index partial on ready rows, and add the next_due due-finder.

Source #createGroupsEmptiedIndexSQL :: Text -> Text -> Text

Index over the summary rows the maintenance triggers emptied in place.

Summary Column Definitions

Source #groupAggregates :: Text -> Text

The group summary aggregates over job rows grouped by group_key. min_id is the id of the head row, the one the claim ranks first. col prefixes each column.

Source #inFlightPredicate :: Text -> Text

Whether a job still holds its group's in-flight slot. col prefixes each column.

Groups Trigger SQL

Source #createGroupsTriggerFunctionsSQL :: Text -> Text -> Text

Group maintenance with indexed extremum replacement. Transition tables supply count deltas. No update or delete scans all rows in an affected group.

Source #createGroupsTriggersSQL :: Text -> Text -> Text

The three statement-level AFTER triggers calling a queue's groups maintenance functions, each handed its affected rows through a transition table.