Skip to content

feat: add DELETE endpoints for evaluations/submissions + fix schema-lock contention - #242

Merged
tmimmanuel merged 2 commits into
mainfrom
dev
Jul 23, 2026
Merged

feat: add DELETE endpoints for evaluations/submissions + fix schema-lock contention#242
tmimmanuel merged 2 commits into
mainfrom
dev

Conversation

@tmimmanuel

Copy link
Copy Markdown
Collaborator

Summary

  • validator/src/eval_backend/db.py: ensure_schema() no longer takes an exclusive ALTER TABLE lock on every process boot when the schema is already up to date — checks information_schema first. Keeps a 5s lock_timeout as a safety net. Fixes a real issue hit this session where a busy job's transaction blocked every new API/worker startup, and by lock-queue fairness, blocked an already-running API server's unrelated queries too.
  • validator/src/eval_backend/api/routes.py: new DELETE /api/admin/evaluations/{id} (standalone provider-route evals only) and DELETE /api/admin/submissions/{id}, backing the new delete buttons in the admin UI (companion PR in mini-router.github.io). Both clear referencing Artifact/JobQueue rows first (no ON DELETE cascade on those FKs in Postgres).

Test plan

  • pytest passes (19 passed, 18 skipped)
  • Verified live against the running validator: DELETE /evaluations/{id} returns 404 for unknown id, 204 + row gone for a real standalone eval; DELETE /submissions/{id} returns 204 + row gone from leaderboard, 404 on repeat delete
  • Verified live: started a new worker process while two jobs were mid-flight — no lock contention, both processed concurrently

tmimmanuel and others added 2 commits July 23, 2026 06:14
ensure_schema() ran ALTER TABLE ... ADD COLUMN IF NOT EXISTS
unconditionally on every process start (API and worker), even though
the columns are normally already present. ALTER TABLE takes an
exclusive lock, and Postgres queues later requests -- including plain
SELECTs -- behind a pending exclusive lock request, so a long-running
job transaction could block not just new process startups but every
already-running process's unrelated queries too.

Add _add_column_if_missing/_drop_not_null_if_needed helpers that check
information_schema first (a non-blocking catalog SELECT) and only take
the exclusive lock when a migration is actually needed. A 5s
lock_timeout remains as a safety net for the rare case a migration is
genuinely needed while something else is busy, so that case fails fast
with a clear error instead of hanging indefinitely.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Adds DELETE /api/admin/evaluations/{id} (restricted to standalone
provider-route evals, i.e. submission_id is null) and
DELETE /api/admin/submissions/{id}, for the admin UI's new delete
buttons on the provider-tests and standings tables.

Both endpoints clear referencing Artifact/JobQueue rows first since
those FKs have no ON DELETE cascade in Postgres, then delete the
target row (submission deletion cascades to its TrainRun/EvaluationRun
rows via the existing ORM-level cascade="all, delete-orphan").

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@github-actions github-actions Bot added eval Evaluation changes validator Validator backend changes labels Jul 23, 2026
@tmimmanuel
tmimmanuel merged commit 16bf2e9 into main Jul 23, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

eval Evaluation changes validator Validator backend changes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant