From 0bc8a211ec912308a2414bfc6de93b0a6495acc5 Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Fri, 3 Oct 2025 14:34:07 +0200 Subject: [PATCH] Bug 40947: Remove warning "Aborted connection" from t/db_dependent/www/search_utf8.t We sent a SIGKILL to the daemon which does not let it cleanup Updating to SIGTERM (15) and handle the dbh disconnect gracefully in the daemon. Also handle SIGINT (ctrl+c) only because I think it can be useful (?) Test plan: prove t/db_dependent/www/search_utf8.t => Without this patch there are 3 warnings in the DB container log db-1 | 2025-10-03 12:30:57 362 [Warning] Aborted connection 42 to db: 'koha_kohadev' user: 'koha_kohadev' host: '172.19.0.6' (Got an error reading communication packets) => With this patch applied there are none. --- misc/migration_tools/rebuild_zebra.pl | 11 +++++++++++ t/lib/Mocks/Zebra.pm | 4 ++-- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/misc/migration_tools/rebuild_zebra.pl b/misc/migration_tools/rebuild_zebra.pl index ffaa63391d6..a4a9410ee53 100755 --- a/misc/migration_tools/rebuild_zebra.pl +++ b/misc/migration_tools/rebuild_zebra.pl @@ -254,6 +254,17 @@ my $dbh; # option (wait-for-lock) is provided to let the program wait for the lock. # See https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=11078 for details. if ($daemon_mode) { + + $SIG{TERM} = sub { + $dbh->disconnect if $dbh; + exit 0; + }; + + $SIG{INT} = sub { + $dbh->disconnect if $dbh; + exit 0; + }; + while (1) { # For incremental updates, skip the update if the updates are locked diff --git a/t/lib/Mocks/Zebra.pm b/t/lib/Mocks/Zebra.pm index 6c2c184a4f1..68808df880b 100644 --- a/t/lib/Mocks/Zebra.pm +++ b/t/lib/Mocks/Zebra.pm @@ -274,8 +274,8 @@ Missing POD for cleanup. sub cleanup { my ($self) = @_; - kill 9, $self->{zebra_pid} if defined $self->{zebra_pid}; - kill 9, $self->{indexer_pid} if defined $self->{indexer_pid}; + kill 15, $self->{zebra_pid} if defined $self->{zebra_pid}; + kill 15, $self->{indexer_pid} if defined $self->{indexer_pid}; # Clean up the Zebra files since the child process was just shot rmtree $self->{datadir}; -- 2.34.1