feat(practice): run practice jobs on the code runner with one stored result per run
This commit is contained in:
1 parent
9385b2ddd4
commit
9344228e84
17 files changed
+1010
-35
No files matched your search
@@ -0,0 +1,20 @@
|
||||
-- +goose Up
|
||||
-- A finished practice job keeps the opaque run ID under which the code runner
|
||||
-- held the run that produced the stored result. The ID is the HMAC-derived
|
||||
-- value of the run key (attempt item, submission, generation) that the runner
|
||||
-- itself logs, so an operator can match a stored result to one runner run
|
||||
-- without the runner learning who the candidate is. Only the finishing try
|
||||
-- writes it, in the transaction that stores the result; a failed or unfinished
|
||||
-- job has none. The ID is unique, because one run produces at most one result.
|
||||
ALTER TABLE assessment_practice_jobs
|
||||
ADD COLUMN runner_run_id uuid,
|
||||
ADD CONSTRAINT assessment_practice_jobs_runner_run_state CHECK (
|
||||
runner_run_id IS NULL OR state = 'finished'
|
||||
),
|
||||
ADD CONSTRAINT assessment_practice_jobs_runner_run_key UNIQUE (runner_run_id);
|
||||
|
||||
-- +goose Down
|
||||
ALTER TABLE assessment_practice_jobs
|
||||
DROP CONSTRAINT assessment_practice_jobs_runner_run_key,
|
||||
DROP CONSTRAINT assessment_practice_jobs_runner_run_state,
|
||||
DROP COLUMN runner_run_id;
|
||||
@@ -149,11 +149,13 @@ WHERE
|
||||
id = sqlc.arg(id)
|
||||
AND result IS NULL;
|
||||
|
||||
-- Ends a running try as finished or failed.
|
||||
-- Ends a running try as finished or failed. A finished job keeps the run ID
|
||||
-- of the runner run that produced its result.
|
||||
-- name: FinishAssessmentPracticeJob :execrows
|
||||
UPDATE assessment_practice_jobs
|
||||
SET
|
||||
state = sqlc.arg(state),
|
||||
runner_run_id = sqlc.narg(runner_run_id),
|
||||
finished_at = greatest(created_at, clock_timestamp()),
|
||||
last_error_class = coalesce(sqlc.narg(error_class), last_error_class),
|
||||
lease_owner = NULL,
|
||||
|
||||
Reference in new issue
Block a user