Skip to main content

Module claims

Module claims 

Source
Expand description

Claiming due rows for a worker phase.

Every claim takes up to limit due rows in its states, the longest due first. The row locks live until the caller’s transaction ends, so callers must pass a transaction. Rows on a paused course module, or on one whose credit registration has been switched off, are never claimed: enforced here so no phase can forget it. Both freeze a row where it stands rather than cancelling it, so switching the module back on resumes the rows that were already in flight.

An unscoped claim (the live background worker) also skips a row whose user (and, if the hold names one, course) has a live row in credit_registration_test_exclusive_holds. A scoped claim always ignores holds, so a spec driving its own rows through explicit ticks is unaffected either way.

Structs§

RegistrationScope
Which rows a phase iteration may touch. Empty means every row, which is what production runs; a narrowed scope lets a test drive the pipeline for its own course on a shared database.

Enums§

ClaimKind 🔒
Which caller a claim is for, which decides the rows that hold a row back and the order.
VerifyFlow
Which of verify’s flows a claim is for.

Constants§

LOOKUP_STATES 🔒
The states resolve-enrolments looks up from: rows on their way to a first resolve, and rows parked in no_usable_enrolment whose next enrolment check is due, which are checked where they stand.
VERIFY_STATES 🔒
The states verify polls from. Withdrawal moves a row out of all of them, which is what stops the polling without any query having to know about withdrawal.

Functions§

claim 🔒
Shares its eligibility filters with count_due_enrolment_checks and pull_forward_batched_checks; change all three together.
claim_due_for_import
Claims, for import, checking_enrolment rows, minus any whose student and course code already have a submission in flight, which Suotar’s hour-old copy of Sisu would not stop from registering twice, and any whose person and module slot in uq_credit_registrations_person_module is taken. Of two rows for the same student and course code claimed together only the first comes back; the other stays claimable where it is.
claim_due_for_person_lookup
Claims, for the person lookup that precedes resolve-enrolments, the rows claim_due_for_resolve would take, the later EnrolmentCheckGroup first.
claim_due_for_resolve
Claims, for resolve-enrolments, ready_to_submit rows and parked rows due an enrolment check, the later EnrolmentCheckGroup first, minus any whose student already has another live row for the module somewhere between resolving and a known outcome. First pulls slow checks due soon into the batch; see crate::library::credit_registration::enrolment_checks::pull_forward_batched_checks.
claim_due_for_verify
Claims rows for one of verify’s flows. Each flow is claimed on its own, so that rows one flow has no allowance to send cannot fill the other’s claim.
claim_enrolment_checks
Keeps parked rows out of every claim while a lookup for them is out, as resolving_enrolment does for a row on its first resolve. The answer’s transition ends the claim; one a worker died holding expires after RESOLVING_RECOVERY_GRACE. A no-op for a row in any other state.
first_per 🔒
The first of the claimed rows per key. The claim query holds back a row whose twin is already in flight, but cannot see a twin claimed alongside it; the rows dropped here keep their lock until the claim’s transaction ends, and are claimable where they are after it.