Bug 16758 - Caching issues in scripts running in daemon mode

As L1 cache does not have expiration mechanism, scripts running
in daemon mode (rebuild_zebra.pl -daemon, sip server ?, ...) would
not be aware of any possible changes in the data being cached
in upstream L2 cache.

This patch adds ->flush_L1_caches() call in rebuild_zebra.pl
inside daemon mode loop.

To test:

1) apply patch
2) ensure that rebuild_zebra.pl -daemon is still working properly,
without any noticeable performance degradation
3) stop memcached daemon and try to run rebuild_zebra.pl -daemon
again: there should be a warning emitted stating that the script
is running in daemon mode but without recommended caching system

Signed-off-by: Josef Moravec <josef.moravec@gmail.com>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
(cherry picked from commit 84dbc80074)
Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
This commit is contained in:
Jacek Ablewicz 2016-09-14 15:33:07 +02:00 committed by Mason James
parent dcdf1dcdac
commit f178fd076b
1 changed files with 9 additions and 1 deletions

View File

@ -26,6 +26,7 @@ use C4::Biblio;
use C4::AuthoritiesMarc;
use C4::Items;
use Koha::RecordProcessor;
use Koha::Caches;
use XML::LibXML;
use constant LOCK_FILENAME => 'rebuild..LCK';
@ -63,6 +64,7 @@ my $run_user = (getpwuid($<))[0];
my $wait_for_lock = 0;
my $use_flock;
my $table = 'biblioitems';
my $is_memcached = Koha::Caches->get_instance('syspref')->memcached_cache;
my $verbose_logging = 0;
my $zebraidx_log_opt = " -v none,fatal,warn ";
@ -136,6 +138,9 @@ if ($daemon_mode) {
$msg .= "Please do '$0 --help' to see usage.\n";
die $msg;
}
unless ($is_memcached) {
warn "Warning: script running in daemon mode, without recommended caching system (memcached).\n";
}
$authorities = 1;
$biblios = 1;
$process_zebraqueue = 1;
@ -245,7 +250,10 @@ if ($daemon_mode) {
if (_flock($LockFH, LOCK_EX|LOCK_NB)) {
eval {
$dbh = C4::Context->dbh;
do_one_pass() if ( zebraqueue_not_empty() );
if( zebraqueue_not_empty() ) {
Koha::Caches->flush_L1_caches() if $is_memcached;
do_one_pass();
}
};
if ($@ && $verbose_logging) {
warn "Warning : $@\n";