Bug 14361

Summary: koha-restart-zebra fails
Product: Koha Reporter: Benjamin Rokseth <benjamin.rokseth>
Component: Command-line UtilitiesAssignee: Benjamin Rokseth <benjamin.rokseth>
Status: CLOSED FIXED QA Contact: Testopia <testopia>
Severity: major    
Priority: P3 CC: chris, indradg, jonathan.druart, katrin.fischer, liz, mirko, mtj, mtompset, robin, tomascohen
Version: Main   
Hardware: All   
OS: All   
Change sponsored?: --- Patch complexity: ---
Documentation contact: Documentation submission:
Text to go in the release notes:
Version(s) released in:
Attachments: Bug 14361 - koha-restart-zebra fails and probably breaks upgrade
Bug 14361 - koha-restart-zebra fails and probably breaks upgrade
Bug 14361: koha-restart-zebra fails and probably breaks upgrade

Description Benjamin Rokseth 2015-06-07 19:49:52 UTC
Introduction of koha-functions bash lib (Bug 11404) have missed the need of specifying pidfiles directory on restarting/stopping zebra server.

This might also affect Bug 12009 - Sometimes a koha-common restart won't restart zebra, and might break zebra index on update.

Specs: The function is_zebra_running() (and possibly also is_indexer_running() ) will always return 1 (false) even if zebra is running. Thus a koha-restart-zebra/koha-stop-zebra will do nothing.
 
Patch to come.
Comment 1 Benjamin Rokseth 2015-06-08 09:23:47 UTC Comment hidden (obsolete)
Comment 2 Benjamin Rokseth 2015-06-08 09:37:41 UTC
Note that if using gitify or some other way to make a koha dev instance from a standard one, make sure that the referenced file : /usr/share/koha/bin/koha-functions.sh is updated also.
Comment 3 Tomás Cohen Arazi 2015-06-17 12:37:53 UTC
*** Bug 12009 has been marked as a duplicate of this bug. ***
Comment 4 Mason James 2015-06-17 12:43:41 UTC Comment hidden (obsolete)
Comment 5 Mason James 2015-06-17 12:45:19 UTC
works perfectly!, tested on master branch
Comment 6 Tomás Cohen Arazi 2015-06-17 12:48:29 UTC
Created attachment 40235 [details] [review]
Bug 14361: koha-restart-zebra fails and probably breaks upgrade

This patch fixes the koha-restart-zebra and koha-stop-zebra scripts
by adding pidfiles folder to the test is_zebra_running.
It also adds pidfiles to the test is_indexer_running so that
koha-rebuild-zebra will work properly.

Test plan:
1) check if zebrasrv is running, get pid of zebrasrv
   ps ax | grep zebrasrv
2) In my case, there was also a warning on the about.pl page on a fresh
   install: Error message from Zebra: 1011 (bad credentials)
3) try to restart zebra
   koha-restart-zebra instancename
   You will get a msg :
   Zebra does not appear to have been running for instancename
   Starting Zebra server for instancename
4) check again if zebrasrv is running
    ps ax | grep zebrasrv
   and see that pid has not changed, thus it is not restarted
5) Apply patch
6) repeat 4) and watch now how pid has changed
   If there was a warning on about.pl it should now be gone

Signed-off-by: Mason James <mtj@kohaaloha.com>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
Good catch Benjamin! It works as expected with the patch.
Comment 7 Mason James 2015-06-17 12:51:45 UTC
This patch needs to be pulled to 3.16, 3.18 and 3.20 branches
Comment 8 Jonathan Druart 2015-06-23 14:24:52 UTC
Should I see the pid file with
   ps ax | grep zebrasrv
?

Because I don't, with or without the patch.
Comment 9 Mirko Tietgen 2015-06-28 19:55:26 UTC
*** Bug 14466 has been marked as a duplicate of this bug. ***
Comment 10 Mirko Tietgen 2015-06-28 19:58:35 UTC
Does the indexer daemon use a pid file? When I wrote the patch for the duplicate bug I thought it does not, so I did not patch it.

Also

"Note that the --running option must appear before any
           --pidfile or --pidfiles option when checking if another user's
           daemon is running otherwise you might get an error about the
           pidfile directory not being writable."
Comment 11 Benjamin Rokseth 2015-06-28 20:00:33 UTC
Jonathan, yes you should definitely see pidfile dir setting.

ps ax | grep zebrasrv should give two hits:

* the daemon process, which should give the active daemon flags, including --pidfiles=/var/run/koha/[instance]/

* the actual zebrasrv process, with the flags for the server.

example:

1124 ?        S      0:00 daemon --name=name-koha-zebra --pidfiles=/var/run/koha/name/ --errlog=/var/log/koha/name/zebra-error.log --stdout=/var/log/koha/name/zebra.log --output=/var/log/koha/name/zebra-output.log --verbose=1 --respawn --delay=30 --user=name-koha.name-koha -- zebrasrv -v none,fatal,warn -f /etc/koha/sites/name/koha-conf.xml

1136 ?        S      0:00 zebrasrv -v none,fatal,warn -f /etc/koha/sites/name/koha-conf.xml

if you don't see the --pidfiles=/var/run/koha/[instance]/, either the daemon is not running and/or the patch is not applied.

koha-restart-zebra [instance] would attempt to restart daemon
Comment 12 Benjamin Rokseth 2015-06-28 20:07:25 UTC
Mirko, yes zebra daemon uses a pidfile, which is placed in the koha pidfiles dir:

ex.: (my instance is just called 'name')

root@73107be4a833:~# cat /var/run/koha/name/name-koha-zebra.pid 
1124

about the --running and order you seem to be right. I have not noticed any errors, but docs say so.

Please feel free to adjust the patch. It is not pushed yet
Comment 13 Mirko Tietgen 2015-06-28 20:18:28 UTC
What I mean is, there is no --pidfiles used in koha-indexer, while in koha-start-zebra, it is. The latter being the reason why is_zebra_running did not work. I suppose it does not matter for is_indexer_running, but I have not tried. My patch is on Bug 14466.
Comment 14 Mark Tompsett 2015-06-28 20:37:46 UTC
I'm not sure about 3.16.x -- I have QA system running 3.16.{can't remember what} which does not have --pidfiles in the daemon ps list.
Comment 15 Mason James 2015-07-21 02:38:55 UTC
(In reply to M. Tompsett from comment #14)
> I'm not sure about 3.16.x -- I have QA system running 3.16.{can't remember
> what} which does not have --pidfiles in the daemon ps list.

confirmed, its not needed for 3.16 :)
Comment 16 Tomás Cohen Arazi 2015-08-26 14:11:50 UTC
Patch pushed to master.

Thanks Benjamin!
Comment 17 Liz Rea 2015-09-21 04:46:37 UTC
Pushed to 3.18.x will be in 3.18.11
Comment 18 Chris Cormack 2015-09-22 01:08:10 UTC
Pushed to 3.20.x will be in 3.20.4