From 2b586aa4e9623d4961479be13abd3c583a443e90 Mon Sep 17 00:00:00 2001 From: Nick Clemens Date: Wed, 13 Sep 2023 17:03:32 +0000 Subject: [PATCH] Bug 34678: Allow new entries to overwrite hold_fill_targets When using background jobs, there is a possibility of a race condition where two jobs will be updating the holds queue for the same biblio. We should try to minimize those cases (see bug 34596) In the meantime though, we should prevent jobs possibly dying, and allow the most recent update to succeed. There is a possibility two updates wil assign different items to the same reserve, and that a reserve could end up in the queue twice, however, whichever one is filled first will delete both entries. as filling the hold deletes by reserve id (see bug 24359) To test: 1 - prove -v t/db_dependent/Reserves.t 2 - It fails 3 - Apply patch 4 - t/db_dependent/Reserves.t 5 - It succeeds! Signed-off-by: Emily Lamancusa --- C4/HoldsQueue.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/C4/HoldsQueue.pm b/C4/HoldsQueue.pm index 4b811627eb..adcceea23a 100644 --- a/C4/HoldsQueue.pm +++ b/C4/HoldsQueue.pm @@ -776,7 +776,7 @@ sub AddToHoldTargetMap { my $dbh = C4::Context->dbh; my $insert_sql = q( - INSERT INTO hold_fill_targets (borrowernumber, biblionumber, itemnumber, source_branchcode, item_level_request, reserve_id) + REPLACE INTO hold_fill_targets (borrowernumber, biblionumber, itemnumber, source_branchcode, item_level_request, reserve_id) VALUES (?, ?, ?, ?, ?, ?) ); my $sth_insert = $dbh->prepare($insert_sql); -- 2.34.1