Bugzilla – Attachment 148573 Details for
Bug 33309
Race condition while checkout renewal with ES
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 33309: Index items after renewal transaction completes
Bug-33309-Index-items-after-renewal-transaction-comp.patch (text/plain), 2.66 KB, created by
Janusz Kaczmarek
on 2023-03-22 21:39:52 UTC
(
hide
)
Description:
Bug 33309: Index items after renewal transaction completes
Filename:
MIME Type:
Creator:
Janusz Kaczmarek
Created:
2023-03-22 21:39:52 UTC
Size:
2.66 KB
patch
obsolete
>From 18c3a0c63a60916d3cec4a06a372c9b396266a95 Mon Sep 17 00:00:00 2001 >From: Nick Clemens <nick@bywatersolutions.com> >Date: Wed, 22 Mar 2023 19:12:01 +0000 >Subject: [PATCH] Bug 33309: Index items after renewal transaction completes > >This patch ensures a record is indexed only after the renewal transaction >has completed successfully. Otherwise the job cannot be found by the background process >worker, becaue it was not yet in the DB > >To test: >1 - Make sure you are using ES, and the es indexer is running >2 - tail -f /var/log/koha/kohadev/*.log >3 - Issue an item to a patron and renew it >4 - Note error in es-indexer-output.log like: > [2023/03/21 12:22:36] [WARN] No job found for id=157 main:: /kohadevbox/koha/misc/workers/es_indexer_daemon.pl (129) >5 - Apply patch >6 - Renew again >7 There should be no error >8 - Search for the record and confirm items info displays correctly >9 - View the background jobs in admin, confirm the most recent job has completed > >Signed-off-by: Janusz Kaczmarek <januszop@gmail.com> >--- > C4/Circulation.pm | 6 +++++- > Koha/Item.pm | 4 ---- > 2 files changed, 5 insertions(+), 5 deletions(-) > >diff --git a/C4/Circulation.pm b/C4/Circulation.pm >index e190019ae1..a8c5ba9dbb 100644 >--- a/C4/Circulation.pm >+++ b/C4/Circulation.pm >@@ -3161,7 +3161,8 @@ sub AddRenewal { > $renews = ( $item_object->renewals || 0 ) + 1; > $item_object->renewals($renews); > $item_object->onloan($datedue); >- $item_object->store({ log_action => 0 }); >+ # Don't index as we are in a transaction >+ $item_object->store({ log_action => 0, skip_record_index => 1 }); > > # Charge a new rental fee, if applicable > my ( $charge, $type ) = GetIssuingCharges( $itemnumber, $borrowernumber ); >@@ -3246,6 +3247,9 @@ sub AddRenewal { > } > }); > }); >+ # We index now, after the transaction is committed >+ my $indexer = Koha::SearchEngine::Indexer->new({ index => $Koha::SearchEngine::BIBLIOS_INDEX }); >+ $indexer->index_records( $item_object->biblionumber, "specialUpdate", "biblioserver" ); > > return $datedue; > } >diff --git a/Koha/Item.pm b/Koha/Item.pm >index a0a18e5fb1..3fd37cc633 100644 >--- a/Koha/Item.pm >+++ b/Koha/Item.pm >@@ -70,10 +70,6 @@ Koha::Item - Koha Item object class > > $params can take an optional 'skip_record_index' parameter. > If set, the reindexation process will not happen (index_records not called) >- >-NOTE: This is a temporary fix to answer a performance issue when lot of items >-are added (or modified) at the same time. >-The correct way to fix this is to make the ES reindexation process async. > You should not turn it on if you do not understand what it is doing exactly. > > =cut >-- >2.30.2 >
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 33309
:
148569
|
148573
|
148605