Actions
action #153616
closedPrevent `duplicate key value violates unique constraint` on image uploads size:S
Description
Observation¶
Jan 15 11:15:43 susetest openqa-webui-daemon[2989]: [error] Unexpected error when updating job 1 executed by worker susetest:1: DBIx::Class::Storage::DBI::_dbh_execute(): DBI Exception: DBD::Pg::st execute failed: ERROR: duplicate key value violates unique constraint "needles_dir_id_filename"
Jan 15 11:15:43 susetest openqa-webui-daemon[2989]: DETAIL: Key (dir_id, filename)=(1, root-console-20180724.json) already exists. [for Statement "INSERT INTO needles ( dir_id, file_present, filename, last_matched_module_id, last_matched_time, last_seen_module_id, last_seen_time, t_created, t_updated) VALUES ( ?, ?, ?, ?, ?, ?, ?, ?, ? ) RETURNING id" with ParamValues: 1='1', 2='1', 3='root-console-20180724.json', 4='6', 5='2024-01-15 16:15:43', 6='6', 7='2024-01-15 16:15:43', 8='2024-01-15 16:15:43', 9='2024-01-15 16:15:43'] at /usr/share/openqa/script/../lib/OpenQA/Schema/Result/Needles.pm line 79
That happen sometimes in tests scheduled during development of #138302, see also https://github.com/os-autoinst/os-autoinst-distri-openQA/pull/159#issuecomment-1893367879. It possibly leads to tests terminating prematurely without logs being uploaded (because no retry is happening and the problem is considered fatal immediately; due to the missing logs this is yet to be confirmed, though).
Acceptance criteria¶
- AC1: Two jobs uploading the same needle concurrently never run into the error mentioned above
Suggestions¶
- Remove race condition from code pointed out by the error message as well as the creation of the dir lib/OpenQA/Schema/Result/Needles.pm:79
- Test this code against the scenario from #138302:
for i in {01..10} ; do openqa-clone-job --within-instance https://openqa.opensuse.org/tests/3871539 --skip-chained-deps --skip-download TEST=dheidler_mm2_ping_$i BUILD=dheidler_mm2_ping _GROUP=0 PUBLISH_HDD_1= PUBLISH_PFLASH_VARS= ; done
Actions