[Bug 17833] New: Memcached silently fails to _initilize_memcached() on the second time it is invoked
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=17833 Bug ID: 17833 Summary: Memcached silently fails to _initilize_memcached() on the second time it is invoked Change sponsored?: --- Product: Koha Version: master Hardware: All OS: All Status: NEW Severity: enhancement Priority: P5 - low Component: Architecture, internals, and plumbing Assignee: gmcharlt@gmail.com Reporter: olli-antti.kivilahti@jns.fi QA Contact: testopia@bugs.koha-community.org When _initilize_memcached() is called the first time, it sets the 'ismemcached'-key and returns 1. When _initilize_memcached() is called the second time, the 'ismemcached'-key already exists and '' is returned (this default to False in Perl). Koha thinks that memcached is not in use and decides to use some other caching mechanism instead. Cache::Memcached::Fast returns undef on server error: https://metacpan.org/pod/Cache::Memcached::Fast#add Koha MUST listen to undefined, instead of False to define whether or not memcached is properly working. Also added simple helpful diagnostics to help identify and log when this memcached server connection problem arises. Here is a small test run to verify this behaviour: root@kohadev:~# echo "fresh memcached start" fresh memcached start root@kohadev:~# perl l.pl 127.0.0.1:4545 1.4.14 (Ubuntu) def : '1' getkey: 'text' root@kohadev:~# echo "val already cached" val already cached root@kohadev:~# perl l.pl 127.0.0.1:4545 1.4.14 (Ubuntu) def : '' getkey: 'text' root@kohadev:~# echo "memcached killed and not responding" memcached killed and not responding root@kohadev:~# perl l.pl undef getkey: '' root@kohadev:~# echo "The return value is undefined" The return value is undefined root@kohadev:~# Here is the code snippet used to test the Memcached-server in the previous example output: kivilahtio@koha_ci_1 /h/k/Koha> cat t.pl use Cache::Memcached::Fast; use Modern::Perl; my $memd = new Cache::Memcached::Fast({ servers => [ '/lxcBindMount/tmp/memcached.sock' ], namespace => 'koha_ci_1:', connect_timeout => 0.2, io_timeout => 0.5, close_on_error => 1, max_failures => 3, failure_timeout => 2, ketama_points => 150, nowait => 1, hash_namespace => 1, }); # Get server versions. my $versions = $memd->server_versions; while (my ($server, $version) = each %$versions) { print "$server $version\n"; } # Store scalars. my $rv = $memd->add('skey', 'text'); print "undef\n" if not defined $rv; print "def : '$rv'\n" if defined $rv; print "getkey: '".$memd->get('skey')."'\n"; -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=17833 --- Comment #1 from Olli-Antti Kivilahti <olli-antti.kivilahti@jns.fi> --- Created attachment 58554 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=58554&action=edit Bug 17833 - Memcached silently fails to _initilize_memcached() on the second time it is invoked When _initilize_memcached() is called the first time, it sets the 'ismemcached'-key and returns 1. When _initilize_memcached() is called the second time, the 'ismemcached'-key already exists and '' is returned (this default to False in Perl). Koha thinks that memcached is not in use and decides to use some other caching mechanism instead. Cache::Memcached::Fast returns undef on server error: https://metacpan.org/pod/Cache::Memcached::Fast#add Koha MUST listen to undefined, instead of False to define whether or not memcached is properly working. Also added simple helpful diagnostics to help identify and log when this memcached server connection problem arises. -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=17833 Olli-Antti Kivilahti <olli-antti.kivilahti@jns.fi> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |Needs Signoff -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=17833 Olli-Antti Kivilahti <olli-antti.kivilahti@jns.fi> changed: What |Removed |Added ---------------------------------------------------------------------------- Assignee|gmcharlt@gmail.com |olli-antti.kivilahti@jns.fi -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=17833 Jonathan Druart <jonathan.druart@bugs.koha-community.org> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |jonathan.druart@bugs.koha-c | |ommunity.org --- Comment #2 from Jonathan Druart <jonathan.druart@bugs.koha-community.org> --- You are mixing add and set, replace ->add with ->set in your snippet and it will work as expected. Set will return 1 even if the key already exists. It seems that this is invalid, waiting for Olli's confirmation. -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=17833 --- Comment #3 from Olli-Antti Kivilahti <olli-antti.kivilahti@jns.fi> --- Thanks for digging into this Jonathan! You are correct. The culprit was misconfigured socket permission. Same behaviour is expected on any connection issue to the memcached server. I changed the bug title and content to only add warnings when a server/connection problem occurs. -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=17833 --- Comment #4 from Olli-Antti Kivilahti <olli-antti.kivilahti@jns.fi> --- Created attachment 58556 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=58556&action=edit Bug 17833 - _initilize_memcached() warns if errors If memcached or the connection to it is misconfigured, show simple warnings to help identify the problem. -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=17833 Olli-Antti Kivilahti <olli-antti.kivilahti@jns.fi> changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #58554|0 |1 is obsolete| | -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=17833 Olli-Antti Kivilahti <olli-antti.kivilahti@jns.fi> changed: What |Removed |Added ---------------------------------------------------------------------------- Summary|Memcached silently fails to |_initilize_memcached() |_initilize_memcached() on |warns if errors |the second time it is | |invoked | -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=17833 Katrin Fischer <katrin.fischer@bsz-bw.de> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|Needs Signoff |Signed Off -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=17833 Katrin Fischer <katrin.fischer@bsz-bw.de> changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #58556|0 |1 is obsolete| | --- Comment #5 from Katrin Fischer <katrin.fischer@bsz-bw.de> --- Created attachment 68162 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=68162&action=edit Bug 17833 - _initilize_memcached() warns if errors If memcached or the connection to it is misconfigured, show simple warnings to help identify the problem. Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de> -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=17833 Katrin Fischer <katrin.fischer@bsz-bw.de> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |katrin.fischer@bsz-bw.de --- Comment #6 from Katrin Fischer <katrin.fischer@bsz-bw.de> --- Small change, didn't appear to break something in my testing. -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=17833 Marcel de Rooy <m.de.rooy@rijksmuseum.nl> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|Signed Off |Passed QA Patch complexity|--- |Trivial patch -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=17833 Marcel de Rooy <m.de.rooy@rijksmuseum.nl> changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #68162|0 |1 is obsolete| | --- Comment #7 from Marcel de Rooy <m.de.rooy@rijksmuseum.nl> --- Created attachment 70281 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=70281&action=edit Bug 17833 - _initilize_memcached() warns if errors If memcached or the connection to it is misconfigured, show simple warnings to help identify the problem. Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de> Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=17833 Marcel de Rooy <m.de.rooy@rijksmuseum.nl> changed: What |Removed |Added ---------------------------------------------------------------------------- QA Contact|testopia@bugs.koha-communit |m.de.rooy@rijksmuseum.nl |y.org | CC| |m.de.rooy@rijksmuseum.nl -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=17833 --- Comment #8 from Jonathan Druart <jonathan.druart@bugs.koha-community.org> --- Created attachment 70307 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=70307&action=edit Bug 17833: Make sure this warning will not be ignored -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=17833 Jonathan Druart <jonathan.druart@bugs.koha-community.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|Passed QA |Pushed to Master --- Comment #9 from Jonathan Druart <jonathan.druart@bugs.koha-community.org> --- Pushed to master for 18.05, thanks to everybody involved! -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=17833 Nick Clemens <nick@bywatersolutions.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |nick@bywatersolutions.com Status|Pushed to Master |RESOLVED Resolution|--- |FIXED --- Comment #10 from Nick Clemens <nick@bywatersolutions.com> --- Enhancement, skipping for 17.11.x. Awesome work everybody! -- You are receiving this mail because: You are watching all bug changes.
participants (1)
-
bugzilla-daemon@bugs.koha-community.org