Skip to content

Stop insertJobOutputReport from failing on a concurrent duplicate insert - #886

Merged
EdwardKaravakis merged 1 commit into
masterfrom
fix-job-output-report-duplicate-insert
Nov 25, 2026
Merged

EdwardKaravakis merged 1 commit into
masterfrom
fix-job-output-report-duplicate-insert

Conversation

@EdwardKaravakis

Copy link
Copy Markdown
Member

update_job_output_report() in finisher.py first tries an UPDATE (updateJobOutputReport), and only falls back to insertJobOutputReport when 0 rows were updated. Two concurrent callers for the same (PandaID, attemptNr) can both see 0 rows updated and both fall back to the INSERT, and a plain INSERT hits JOB_OUTPUT_REPORT_PK on whichever one commits second - logged as an ORA-00001 error even though the row ends up correctly stored either way.

Replaced the plain INSERT with the same guarded INSERT ... SELECT ... WHERE NOT EXISTS pattern already used by backfill_pilot_attributes, so a losing concurrent attempt becomes a clean no-op instead of a logged constraint violation.

Same bug family as #882 (MetricsDB.update() in metric_collector.py), found while reviewing the panda-server codebase for similar check-then-act races.

Tested live on both backends with a safe, cleaned-up fake PandaID:

  • Production Oracle (aipanda092): first insert succeeds, duplicate insert for the same key is a true no-op with no error, original value preserved, cleanup confirmed.
  • DOMA's Postgres (job_output_report table): identical result - first insert succeeds, duplicate is a no-op, original value preserved, cleanup confirmed.

update_job_output_report() in finisher.py first tries an UPDATE
(updateJobOutputReport), and only falls back to insertJobOutputReport
when 0 rows were updated. Two concurrent callers for the same
(PandaID, attemptNr) can both see 0 rows updated and both fall
back to the INSERT, and a plain INSERT hits JOB_OUTPUT_REPORT_PK on
whichever one commits second, logged as an ORA-00001 error even
though the row ends up correctly stored either way.

Replaced the plain INSERT with the same guarded INSERT ... SELECT
... WHERE NOT EXISTS pattern already used by backfill_pilot_attributes,
so a losing concurrent attempt is a clean no-op instead of a logged
constraint violation.

Tested live on both backends with a safe, cleaned-up fake PandaID:
production Oracle (aipanda092) and DOMA's Postgres (job_output_report
table). On both, the first insert succeeds, a duplicate insert for the
same key is a true no-op with no error, the original value is
preserved, and cleanup is confirmed.
@EdwardKaravakis
EdwardKaravakis force-pushed the fix-job-output-report-duplicate-insert branch from 03e987e to 566d516 Compare November 25, 2026 11:03
@EdwardKaravakis
EdwardKaravakis merged commit 9cd0afd into master Nov 25, 2026
1 check passed
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.

1 participant