From 1631b2849f0ac592da193b72db3ff5a82f3d452d Mon Sep 17 00:00:00 2001 From: Aleisha Amohia Date: Tue, 8 Mar 2022 07:37:18 +1300 Subject: [PATCH] Bug 30260: Add is_indexer_working check Function checks if the zebraqueue has rows that are not 'done' Will depend on a change in checkindex.sh which implements the check: https://git.koha-community.org/Koha-community/global/src/branch/master/koha-zebra/checkindex.sh To test: 1. disable the indexer sudo koha-indexer --stop INSTANCENAME 2. catalogue 5 new records 3. confirm they don't show in any search results 4. in your terminal, go to the shell sudo koha-shell INSTANCENAME 5. run the new script. run with -v for verbose or --rows X to specify how many uncommitted records should be checked for. 5 is the default perl misc/maintenance/check_zebraqueue.pl 6. confirm the script returns that the indexer is not working. The function in koha-functions.sh is required for the pending change to checkindex.sh Sponsored-by: Catalyst IT Signed-off-by: David Nind --- debian/scripts/koha-functions.sh | 9 ++++++ misc/maintenance/check_zebraqueue.pl | 44 ++++++++++++++++++++++++++++ 2 files changed, 53 insertions(+) create mode 100755 misc/maintenance/check_zebraqueue.pl diff --git a/debian/scripts/koha-functions.sh b/debian/scripts/koha-functions.sh index b31b1c6790..6480f1f62b 100755 --- a/debian/scripts/koha-functions.sh +++ b/debian/scripts/koha-functions.sh @@ -213,6 +213,15 @@ is_es_indexer_running() fi } +is_indexer_working() +{ + if ./usr/share/koha/bin/maintenance/check_zebraqueue.pl; then + return 0 + else + return 1 + fi +} + is_worker_running() { local instancename=$1 diff --git a/misc/maintenance/check_zebraqueue.pl b/misc/maintenance/check_zebraqueue.pl new file mode 100755 index 0000000000..5e397184ef --- /dev/null +++ b/misc/maintenance/check_zebraqueue.pl @@ -0,0 +1,44 @@ +#!/usr/bin/perl + +# Copyright 2022 Aleisha Amohia +# +# This file is part of Koha. +# +# Koha is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# Koha is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with Koha; if not, see . + +use Modern::Perl; +use Getopt::Long qw( GetOptions ); +use C4::Context; + +my $verbose = 0; +my $rows = 5; + +GetOptions( + 'v|verbose' => \$verbose, + 'r|rows=i' => \$rows, +); + +my $dbh = C4::Context->dbh; +my $sth = $dbh->prepare("SELECT COUNT(*) FROM zebraqueue WHERE done = ?"); +$sth->execute("0"); + +my ( $count ) = $sth->fetchrow; + +if ( $count > $rows ) { + print "zebraqueue has incomplete rows, so indexer isn't running.\n" if $verbose; + exit 0; +} + +print "zebraqueue does not have enough incomplete rows, we can assume indexer is running.\n" if $verbose; +exit 1; -- 2.30.2