From afe7aaa56cc3105477d4dbeffcafb2b243a3a689 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1s=20Cohen=20Arazi?= Date: Fri, 26 Sep 2025 17:00:44 -0300 Subject: [PATCH] Bug 40890: Make batch_size configurable for koha-es-indexer MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This patch adds a new configuration entry in `koha-conf.xml` for making it possible to set a different `batch_size` for `koha-es-indexer`. The current implementation has a default of *10* that can be overridden using the CLI parameter `--batch_size N`. Unfortunately, if you restart the server or the service without passing the parameter, it will be set back to 10. This patch solves that by adding a new config entry and making the script use it. The passed CLI parameter will keep overridding the configured value. To test: 1. Run: $ ktd --shell k$ koha-es-indexer --restart --batch_size 100 kohadev k$ ps -ef | grep elastic => SUCCESS: No errors. Notice '100' is passed to the called perl script 2. Run: k$ koha-es-indexer --restart kohadev k$ ps -ef | grep elastic => FAIL: Notice '10' is the new value 3. Apply this patch 4. Run: k$ reset_all 5. Repeat 1 and 2 => SUCCESS: '100' is kept. 6. Try standalone `--start` too 7. Sign off :-D --- debian/scripts/koha-es-indexer | 2 +- debian/scripts/koha-functions.sh | 11 +++++++++++ debian/templates/koha-conf-site.xml.in | 3 +++ etc/koha-conf.xml | 3 +++ 4 files changed, 18 insertions(+), 1 deletion(-) diff --git a/debian/scripts/koha-es-indexer b/debian/scripts/koha-es-indexer index c28963f733..e5b67e61fe 100755 --- a/debian/scripts/koha-es-indexer +++ b/debian/scripts/koha-es-indexer @@ -163,7 +163,7 @@ set_action() op="" quiet="no" -batch_size=10 +batch_size=$(get_es_indexer_batch_size ${name}) # Read command line parameters while [ $# -gt 0 ]; do diff --git a/debian/scripts/koha-functions.sh b/debian/scripts/koha-functions.sh index ade6e3c197..fbfe788604 100755 --- a/debian/scripts/koha-functions.sh +++ b/debian/scripts/koha-functions.sh @@ -501,3 +501,14 @@ run_safe_xmlstarlet() echo $(xmlstarlet sel -t -v "yazgfs/config/$myexpr" /etc/koha/sites/$instancename/koha-conf.xml) return 0 } + +get_es_indexer_batch_size() +{ + local instancename=$1 + local retval=$(xmlstarlet sel -t -v 'yazgfs/config/es_indexer_batch_size' /etc/koha/sites/$instancename/koha-conf.xml) + if [ "$retval" != "" ]; then + echo "$retval" + else + echo "10" + fi +} diff --git a/debian/templates/koha-conf-site.xml.in b/debian/templates/koha-conf-site.xml.in index 0e07af36d8..36f632fdb9 100644 --- a/debian/templates/koha-conf-site.xml.in +++ b/debian/templates/koha-conf-site.xml.in @@ -372,6 +372,9 @@ __END_SRU_PUBLICSERVER__ Resetting mappings will override any changes made in the Search engine configuration UI. --> + + 10 + + 10