Skip to content

Create judge tasks for a judging only once. - #3736

Merged
meisterT merged 1 commit into
DOMjudge:mainfrom
meisterT:duplicate_jtasks
Sep 6, 2026
Merged

Create judge tasks for a judging only once.#3736
meisterT merged 1 commit into
DOMjudge:mainfrom
meisterT:duplicate_jtasks

Conversation

@meisterT

@meisterT meisterT commented Sep 2, 2026

Copy link
Copy Markdown
Member

unblockJudgeTasks() checks for judgings without judge tasks and creates them, but two concurrent callers both pass the check. The second set fails on judging_run's unique key with the "1062 Duplicate entry" from #2848 and leaves judge tasks behind that no judging run points at. Lock the judging and re-check inside.

@meisterT
meisterT added this pull request to the merge queue Sep 3, 2026
@meisterT
meisterT removed this pull request from the merge queue due to a manual request Sep 3, 2026
@meisterT

meisterT commented Sep 3, 2026

Copy link
Copy Markdown
Member Author

@tuupke heads-up since you have been removing transactions for #2848: this adds one, but of a different kind.

The ones you removed had the shape that snapshot isolation rejects: plain SELECT, someone else commits, then UPDATE the same row. This one starts with SELECT ... FOR UPDATE on the judging and then only inserts, so the row is locked instead of snapshotted and 'record has changed since last read' cannot happen. It is just a critical section around "check for judge tasks, then create them"; without it two concurrent unblockJudgeTasks() calls both insert, the second fails on judging_run's unique key, and orphaned judgetask rows are left for a judgehost to pick up.

If you would rather have no transaction here, a GET_LOCK per judging like calculateScoreRow should give the same guarantee, but is ugly out of its own right.

@meisterT
meisterT added this pull request to the merge queue Sep 4, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to no response for status checks Sep 4, 2026
@meisterT
meisterT added this pull request to the merge queue Sep 4, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to a conflict with the base branch Sep 4, 2026
@meisterT
meisterT enabled auto-merge September 4, 2026 17:58
unblockJudgeTasks() checks for judgings without judge tasks and creates
them, but two concurrent callers both pass the check. The second set fails
on judging_run's unique key with the "1062 Duplicate entry" from DOMjudge#2848 and
leaves judge tasks behind that no judging run points at. Lock the judging
and re-check inside.
@meisterT
meisterT added this pull request to the merge queue Sep 6, 2026
Merged via the queue into DOMjudge:main with commit 3a45e07 Sep 6, 2026
54 checks passed
@meisterT
meisterT deleted the duplicate_jtasks branch September 6, 2026 16:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants