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§
- Registration
Scope - 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§
- Claim
Kind 🔒 - Which caller a claim is for, which decides the rows that hold a row back and the order.
- Verify
Flow - 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_enrolmentwhose 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_checksandpull_forward_batched_checks; change all three together. - claim_
due_ for_ import - Claims, for import,
checking_enrolmentrows, 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 inuq_credit_registrations_person_moduleis 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_resolvewould take, the laterEnrolmentCheckGroupfirst. - claim_
due_ for_ resolve - Claims, for resolve-enrolments,
ready_to_submitrows and parked rows due an enrolment check, the laterEnrolmentCheckGroupfirst, 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; seecrate::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_enrolmentdoes for a row on its first resolve. The answer’stransitionends the claim; one a worker died holding expires afterRESOLVING_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.