feat(practice): queue practice runs with one running and ten waiting
This commit is contained in:
1 parent
51770eea6c
commit
754c745fba
40 files changed
+3040
-70
No files matched your search
@@ -74,6 +74,11 @@ type Querier interface {
|
||||
// organization already appears in their own access history or is already
|
||||
// hidden. Unknown and unseen organizations produce the same no-row result.
|
||||
CandidateCanSeeOrganization(ctx context.Context, arg CandidateCanSeeOrganizationParams) (CandidateCanSeeOrganizationRow, error)
|
||||
// Claims one job under the queue lock: first a running job whose lease
|
||||
// expired (its worker stopped without finishing it), then the next queued
|
||||
// job, final submissions before debug runs. A takeover keeps the generation,
|
||||
// so the runner returns the run it already has, and counts one attempt.
|
||||
ClaimAssessmentPracticeJob(ctx context.Context, arg ClaimAssessmentPracticeJobParams) (ClaimAssessmentPracticeJobRow, error)
|
||||
// Claims the most overdue delivery that the sending worker may send, in one
|
||||
// statement: a pending, waiting_quota, or scheduled unknown delivery of the service mail kinds
|
||||
// (the literals match the predicate of deliveries_due_idx, so an idle poll
|
||||
@@ -148,6 +153,11 @@ type Querier interface {
|
||||
// returned registration version in the same transaction, rolled back when it
|
||||
// matches no row.
|
||||
ConsumeEmailToken(ctx context.Context, arg ConsumeEmailTokenParams) (ConsumeEmailTokenRow, error)
|
||||
// Counts the queued and running jobs; the caller holds the queue lock.
|
||||
CountActiveAssessmentPracticeJobs(ctx context.Context) (int32, error)
|
||||
// Counts the unfinished debug runs of a practice; the caller holds the
|
||||
// practice row lock.
|
||||
CountActiveAssessmentPracticeRuns(ctx context.Context, practiceID pgtype.UUID) (int32, error)
|
||||
// Count events only for the already owner-locked attempt.
|
||||
CountAssessmentSignalEvents(ctx context.Context, attemptID pgtype.UUID) (int64, error)
|
||||
// Counts the hiding records of one candidate for the settings read.
|
||||
@@ -163,6 +173,9 @@ type Querier interface {
|
||||
// row stays attributed to the organization that consumed it.
|
||||
CountCompanyInvitationQuotaHoldingWindow(ctx context.Context, arg CountCompanyInvitationQuotaHoldingWindowParams) (CountCompanyInvitationQuotaHoldingWindowRow, error)
|
||||
CountCompanyInvitationQuotaWindow(ctx context.Context, arg CountCompanyInvitationQuotaWindowParams) (CountCompanyInvitationQuotaWindowRow, error)
|
||||
// Counts running jobs whose lease has not expired by now, the application
|
||||
// clock; the caller holds the queue lock.
|
||||
CountLiveRunningAssessmentPracticeJobs(ctx context.Context, now pgtype.Timestamptz) (int32, error)
|
||||
// Counts the invitations of one organization need that wait for an answer:
|
||||
// delivered, viewed, or the planned counter offer. The send counts them under
|
||||
// the organization lock, which every send takes first, so no other send can
|
||||
@@ -272,6 +285,9 @@ type Querier interface {
|
||||
// sets the timeout reason. No row is returned when it lost a race or the
|
||||
// deadline has not passed.
|
||||
ExpireInvitation(ctx context.Context, arg ExpireInvitationParams) (pgtype.UUID, error)
|
||||
// Renews the lease of a running try. The owner and the start time identify
|
||||
// the try, so a worker whose job was taken over changes nothing.
|
||||
ExtendAssessmentPracticeJobLease(ctx context.Context, arg ExtendAssessmentPracticeJobLeaseParams) (int64, error)
|
||||
// Records a failed attempt after its handler transaction rolled back: the
|
||||
// job waits for its retry at retry_at (status failed) or is dead, with a
|
||||
// NULL retry_at. due_at keeps the deadline. The same guard as the
|
||||
@@ -291,6 +307,8 @@ type Querier interface {
|
||||
// made at or after reserved_since. A retry of the delivery inside the
|
||||
// provider's idempotency window reuses it instead of counting again.
|
||||
FindOpenMailQuotaReservation(ctx context.Context, arg FindOpenMailQuotaReservationParams) (FindOpenMailQuotaReservationRow, error)
|
||||
// Ends a running try as finished or failed.
|
||||
FinishAssessmentPracticeJob(ctx context.Context, arg FinishAssessmentPracticeJobParams) (int64, error)
|
||||
// Reads the durable active deletion request when an earlier request already
|
||||
// exists. A completed request does not suppress a later explicit request.
|
||||
GetActiveAccountDeletionRequest(ctx context.Context, subjectID pgtype.UUID) (GetActiveAccountDeletionRequestRow, error)
|
||||
@@ -317,6 +335,9 @@ type Querier interface {
|
||||
GetAssessmentClientSignalTotals(ctx context.Context, attemptID pgtype.UUID) (GetAssessmentClientSignalTotalsRow, error)
|
||||
GetAssessmentFamilyByID(ctx context.Context, id pgtype.UUID) (AssessmentFamily, error)
|
||||
GetAssessmentFamilyVersion(ctx context.Context, arg GetAssessmentFamilyVersionParams) (AssessmentFamily, error)
|
||||
// Reads what a claimed job runs: the submission and the task of its
|
||||
// practice.
|
||||
GetAssessmentPracticeJobWork(ctx context.Context, submissionID pgtype.UUID) (GetAssessmentPracticeJobWorkRow, error)
|
||||
// Reads a debug run of the owner's attempt with the state of its job.
|
||||
GetAssessmentPracticeRun(ctx context.Context, arg GetAssessmentPracticeRunParams) (GetAssessmentPracticeRunRow, error)
|
||||
// The attempt a review job works on: real attempts only.
|
||||
@@ -497,7 +518,7 @@ type Querier interface {
|
||||
InsertAssessmentOriginMark(ctx context.Context, arg InsertAssessmentOriginMarkParams) error
|
||||
InsertAssessmentPractice(ctx context.Context, arg InsertAssessmentPracticeParams) error
|
||||
// Queues the execution job of a submission in the transaction that stores
|
||||
// the submission.
|
||||
// the submission. The job is available at once.
|
||||
InsertAssessmentPracticeJob(ctx context.Context, arg InsertAssessmentPracticeJobParams) error
|
||||
InsertAssessmentPracticeSubmission(ctx context.Context, arg InsertAssessmentPracticeSubmissionParams) error
|
||||
InsertAssessmentReviewRead(ctx context.Context, arg InsertAssessmentReviewReadParams) error
|
||||
@@ -859,6 +880,13 @@ type Querier interface {
|
||||
LockAssessmentCategory(ctx context.Context, category string) error
|
||||
// Locks one practice of the owner's attempt for a state change.
|
||||
LockAssessmentPractice(ctx context.Context, arg LockAssessmentPracticeParams) (LockAssessmentPracticeRow, error)
|
||||
// The practice queue. Admission and the claim take the same
|
||||
// transaction-scoped advisory lock, so the count of unfinished jobs and the
|
||||
// change that depends on it are atomic across backend instances. A command
|
||||
// takes the lock after its attempt and practice row locks; the claim takes
|
||||
// it first and then skips job rows that another transaction locks, so a
|
||||
// claim never waits for a row lock while it holds the queue lock.
|
||||
LockAssessmentPracticeQueue(ctx context.Context) error
|
||||
// Serializes the evaluations of one review. A job takes these locks for every
|
||||
// attempt it will write, in ascending attempt order, before it reads any fact,
|
||||
// so what it reads is what the previous writer committed.
|
||||
@@ -880,6 +908,9 @@ type Querier interface {
|
||||
// keeps the consent-revoked reason after later grants. The returned time is
|
||||
// the effective close time used by the privacy history event.
|
||||
LockCandidatePublicationForConsentRevocation(ctx context.Context, arg LockCandidatePublicationForConsentRevocationParams) (pgtype.Timestamptz, error)
|
||||
// Locks a running try for its completion and checks that it still belongs
|
||||
// to the worker.
|
||||
LockClaimedAssessmentPracticeJob(ctx context.Context, arg LockClaimedAssessmentPracticeJobParams) (string, error)
|
||||
// Locks the delivery row of the lease holder until the transaction ends, so
|
||||
// every path that settles a send takes the delivery lock before the quota
|
||||
// rows, the same order as the claim. No row means that owner no longer holds
|
||||
@@ -1158,6 +1189,9 @@ type Querier interface {
|
||||
ReleaseScheduledJobs(ctx context.Context, arg ReleaseScheduledJobsParams) ([]int64, error)
|
||||
// A new repository starts pending; a known one only records the request.
|
||||
RequestCandidateProjectRepositoryCheck(ctx context.Context, arg RequestCandidateProjectRepositoryCheckParams) error
|
||||
// Puts a running try back into the queue: after a busy runner, a failed
|
||||
// try, or at shutdown. counted adds the try to the attempts.
|
||||
RequeueAssessmentPracticeJob(ctx context.Context, arg RequeueAssessmentPracticeJobParams) (int64, error)
|
||||
// Stores the replay record of a command. A record whose retention has passed
|
||||
// is replaced, so the key is accepted as new after the retention. A live
|
||||
// record is left as it is and nothing is returned; the caller then reads it
|
||||
@@ -1218,6 +1252,9 @@ type Querier interface {
|
||||
// handler, which releases the job row lock so the job can be reclaimed once
|
||||
// its lease expires.
|
||||
SetScheduledJobTransactionTimeouts(ctx context.Context, arg SetScheduledJobTransactionTimeoutsParams) error
|
||||
// Moves the practice of a final submission out of pending, but only while
|
||||
// that submission is the latest final one of the practice.
|
||||
SettleAssessmentPracticeAfterJob(ctx context.Context, arg SettleAssessmentPracticeAfterJobParams) (int64, error)
|
||||
// Starts a claimed attempt right before its handler transaction: it renews
|
||||
// the lease from now and records the start, committed on its own. It
|
||||
// changes nothing when the lease already expired by now or no longer
|
||||
@@ -1229,6 +1266,8 @@ type Querier interface {
|
||||
// fictitious provider attempt, for example when the 23-hour safety cutoff is
|
||||
// reached after the claim but before the provider call.
|
||||
StopUnknownDeliveryRetry(ctx context.Context, arg StopUnknownDeliveryRetryParams) (int64, error)
|
||||
// Stores the result of a submission once; a second result changes nothing.
|
||||
StoreAssessmentPracticeResult(ctx context.Context, arg StoreAssessmentPracticeResultParams) (int64, error)
|
||||
// Records activity on an active session and reports whether it is active.
|
||||
// The row is written only when last_seen_at is older than touch_cutoff, so
|
||||
// frequent requests do not rewrite it. last_seen_at never moves back, and a
|
||||
|
||||
Reference in new issue
Block a user