Bug 17342

Summary: Plack does not work after upgrading to 3.22.11 and 16.05.04
Product: Koha Reporter: Josef Moravec <josef.moravec>
Component: Architecture, internals, and plumbingAssignee: Andreas Jonsson <andreas.jonsson>
Status: CLOSED FIXED QA Contact: Testopia <testopia>
Severity: major    
Priority: P5 - low CC: andreas.jonsson, f.demians, jonathan.druart, julian.maurice, katrin.fischer, mirko, tomascohen
Version: 16.05   
Hardware: All   
OS: All   
See Also: https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=17262
Change sponsored?: --- Patch complexity: ---
Documentation contact: Documentation submission:
Text to go in the release notes:
Version(s) released in:
Attachments: Bug 17342: (bug 17262 follow-up) fix the way to retrieve memcached config from apache
Bug 17342: (bug 17262 follow-up) fix the way to retrieve memcached config from apache
Bug 17342: (bug 17262 follow-up) fix the way to retrieve memcached config from apache

Description Josef Moravec 2016-09-23 15:38:11 UTC
After upgrade to 3.22.11, plack does not start
I used debian packages to install

plack-error.log:

Use of uninitialized value $ip in hash element at /usr/share/perl5/Cache/Memcached.pm line 267.
Use of uninitialized value $ip in index at /usr/share/perl5/Cache/Memcached.pm line 293.
Use of uninitialized value in subroutine entry at /usr/share/perl5/Cache/Memcached.pm line 302.
Use of uninitialized value $ip in hash element at /usr/share/perl5/Cache/Memcached.pm line 267.
Use of uninitialized value $ip in index at /usr/share/perl5/Cache/Memcached.pm line 293.
Use of uninitialized value in subroutine entry at /usr/share/perl5/Cache/Memcached.pm line 302.
Error while loading /etc/koha/plack.psgi: Bad arg length for Socket::pack_sockaddr_in, length is 0, should be 4 at /usr/lib/x86_64-linux-gnu/perl5/5.20/Socket.pm line 833.
BEGIN failed--compilation aborted at /usr/share/koha/lib/C4/Context.pm line 107.
Compilation failed in require at /usr/share/koha/lib/C4/Branch.pm line 22.
BEGIN failed--compilation aborted at /usr/share/koha/lib/C4/Branch.pm line 22.
Compilation failed in require at /etc/koha/plack.psgi line 30.
BEGIN failed--compilation aborted at /etc/koha/plack.psgi line 30.
Comment 1 Andreas Jonsson 2016-09-23 23:13:56 UTC
The same problem is in koha 16.05.04 using the debian packages.

The problem is that the memcached configuration variables are extracted from the apache configuration file incorrectly so you get  '"127.0.0.1:11211"' including double quotes as the servers parameter to memcached.  The below patch for koha-functions.sh fixes the problem.

It is not nice to extract configuration from the apache configuration files like this.  I would prefer if the memcached configuration was moved to the koha configuration file.

diff --git a/debian/scripts/koha-functions.sh b/debian/scripts/koha-functions.sh
index b6f1203..1e1d209 100755
--- a/debian/scripts/koha-functions.sh
+++ b/debian/scripts/koha-functions.sh
@@ -50,7 +50,7 @@ get_memcached_servers_for()
     local apache_file=$(get_apache_config_for $instance)
     local memcached_servers=$(
         grep 'MEMCACHED_SERVERS' ${apache_file} |
-        awk '{print $3}' | uniq
+        awk -F'[\t "]+' '{print $4}' | head -n 1
     )
 
     echo "${memcached_servers}"
@@ -63,7 +63,7 @@ get_memcached_namespace_for()
     local apache_file=$(get_apache_config_for $instance)
     local memcached_namespace=$(
         grep 'MEMCACHED_NAMESPACE' ${apache_file} |
-        awk '{print $3}' | uniq
+        awk -F'[\t "]+' '{print $4}' | head -n 1
     )
 
     echo "${memcached_namespace}"
Comment 2 Josef Moravec 2016-09-26 05:54:59 UTC
In master the memcache configuration is set in koha-conf file, so I think for stable versions we could adapt this quick fix.

See bug 11921
Comment 3 Jonathan Druart 2016-10-03 08:02:57 UTC
(In reply to Josef Moravec from comment #2)
> In master the memcache configuration is set in koha-conf file, so I think
> for stable versions we could adapt this quick fix.
> 
> See bug 11921

Do you have a good idea for the fix?
I really do not like the patch from bug 17262 actually. It won't work if the first virtualhost (from the apache config file) does not have a memcached config defined but the second has. It won't work either if the 2 are configured but are different.
Comment 4 Jonathan Druart 2016-10-03 08:05:56 UTC
(In reply to Jonathan Druart from comment #3)
> (In reply to Josef Moravec from comment #2)
> > In master the memcache configuration is set in koha-conf file, so I think
> > for stable versions we could adapt this quick fix.
> > 
> > See bug 11921
> 
> Do you have a good idea for the fix?
> I really do not like the patch from bug 17262 actually. It won't work if the
> first virtualhost (from the apache config file) does not have a memcached
> config defined but the second has. It won't work either if the 2 are
> configured but are different.

I think we don't have a solution for these 2 cases actually and we will have to assume it will not happen (or not taken into account).
Comment 5 Jonathan Druart 2016-10-03 08:09:34 UTC
Created attachment 55967 [details] [review]
Bug 17342: (bug 17262 follow-up) fix the way to retrieve memcached config from apache

The problem is that the memcached configuration variables are extracted
from the apache configuration file incorrectly so you get
'"127.0.0.1:11211"' including double quotes as the servers parameter to
memcached.
Comment 6 Mirko Tietgen 2016-10-03 08:56:12 UTC
The fast fix is to disable memcached and wait for the real fix.

I already built two package versions for 16.05.04 because of this. I am not doing another before this has been resolved properly. For the time being, comment out memcached in your config while I am on vacation. :)
Comment 7 Chris Cormack 2016-10-04 21:29:44 UTC
Created attachment 56040 [details] [review]
Bug 17342: (bug 17262 follow-up) fix the way to retrieve memcached config from apache

The problem is that the memcached configuration variables are extracted
from the apache configuration file incorrectly so you get
'"127.0.0.1:11211"' including double quotes as the servers parameter to
memcached.

Signed-off-by: Chris Cormack <chrisc@catalyst.net.nz>

Note this only applies on 3.22.x but it does fix the problem
Definitely needed for 3.22.12
Comment 8 Jonathan Druart 2016-10-05 07:13:49 UTC
Created attachment 56048 [details] [review]
Bug 17342: (bug 17262 follow-up) fix the way to retrieve memcached config from apache

The problem is that the memcached configuration variables are extracted
from the apache configuration file incorrectly so you get
'"127.0.0.1:11211"' including double quotes as the servers parameter to
memcached.

Signed-off-by: Chris Cormack <chrisc@catalyst.net.nz>

Note this only applies on 3.22.x but it does fix the problem
Definitely needed for 3.22.12

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Comment 9 Jonathan Druart 2016-10-05 07:14:55 UTC
(In reply to Chris Cormack from comment #7)
> Note this only applies on 3.22.x but it does fix the problem
> Definitely needed for 3.22.12

It's needed for 16.05.x as well.
Comment 10 Frédéric Demians 2016-10-05 07:20:09 UTC
Pushed in 16.05. Will be in 16.05.05.
Comment 11 Julian Maurice 2016-10-14 12:36:09 UTC
Pushed to 3.22.x, will be in 3.22.12