Bug 17376 - rebuild_zebra.pl in daemon mode no database access kills the process
Summary: rebuild_zebra.pl in daemon mode no database access kills the process
Status: CLOSED FIXED
Alias: None
Product: Koha
Classification: Unclassified
Component: Command-line Utilities (show other bugs)
Version: master
Hardware: All All
: P5 - low major (vote)
Assignee: Fridolin SOMERS
QA Contact: Testopia
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2016-09-29 14:45 UTC by Fridolin SOMERS
Modified: 2017-06-14 22:13 UTC (History)
7 users (show)

See Also:
Change sponsored?: ---
Patch complexity: Trivial patch
Bot Control: ---
When did the bot last check this:
Who signed the patch off:
Text to go in the release notes:


Attachments
Bug 17376 - rebuild_zebra.pl in daemon mode no database access kills the process (2.96 KB, patch)
2016-09-29 15:09 UTC, Fridolin SOMERS
Details | Diff | Splinter Review
Bug 17376 - rebuild_zebra.pl in daemon mode no database access kills the process (3.01 KB, patch)
2016-09-29 17:15 UTC, Jacek Ablewicz
Details | Diff | Splinter Review
Bug 17376 - rebuild_zebra.pl in daemon mode no database access kills the process (3.07 KB, patch)
2016-10-24 13:38 UTC, Jonathan Druart
Details | Diff | Splinter Review

Note You need to log in before you can comment on or make changes to this bug.
Description Fridolin SOMERS 2016-09-29 14:45:57 UTC
When running rebuild_zebra.pl in daemon mode, a while loop runs the script for ever.
But if something crashes inside the rebuild process, the all daemon crashes.
For example when it can not access database.
This problem may be temporary so daemon should keep running.
Comment 1 Fridolin SOMERS 2016-09-29 15:09:13 UTC
Created attachment 55930 [details] [review]
Bug 17376 - rebuild_zebra.pl in daemon mode no database access kills the process

When running rebuild_zebra.pl in daemon mode, a while loop runs the script for ever.
But if something crashes inside the rebuild process, the all daemon crashes.
For example when it can not access database.
This problem may be temporary so daemon should keep running.

This patch add eval around the rebuild process to allow a run to fail without killing the daemon.
Also moves the DB handler get inside daemon loop because it is broken is DB stoppes.

This is a big issue for indexer running in a systemd service.

Test plan :
- run rebuild_zebra.pl in daemon mode :
/home/koha/src/misc/migration_tools/rebuild_zebra.pl -daemon -z -a -b -x --sleep 30
- stop the database
- wait a minute
=> you see an error on database connexion
=> the daemon is still running
- restart the database
- test the indexer by creating a new record (wait for a minute)
Comment 2 Jacek Ablewicz 2016-09-29 17:15:20 UTC
Created attachment 55938 [details] [review]
Bug 17376 - rebuild_zebra.pl in daemon mode no database access kills the process

When running rebuild_zebra.pl in daemon mode, a while loop runs the script for ever.
But if something crashes inside the rebuild process, the all daemon crashes.
For example when it can not access database.
This problem may be temporary so daemon should keep running.

This patch add eval around the rebuild process to allow a run to fail without killing the daemon.
Also moves the DB handler get inside daemon loop because it is broken is DB stoppes.

This is a big issue for indexer running in a systemd service.

Test plan :
- run rebuild_zebra.pl in daemon mode :
/home/koha/src/misc/migration_tools/rebuild_zebra.pl -daemon -z -a -b -x --sleep 30
- stop the database
- wait a minute
=> you see an error on database connexion
=> the daemon is still running
- restart the database
- test the indexer by creating a new record (wait for a minute)

Signed-off-by: Jacek Ablewicz <abl@biblos.pk.edu.pl>
Comment 3 Jonathan Druart 2016-09-30 08:30:15 UTC
The error "Can't connect to local MySQL server through socket" will be output to stderr anyway (regardless $verbose). Is it expected?
Comment 4 Fridolin SOMERS 2016-10-05 13:57:17 UTC
(In reply to Jonathan Druart from comment #3)
> The error "Can't connect to local MySQL server through socket" will be
> output to stderr anyway (regardless $verbose). Is it expected?

Yes I think this is better to know it does not work.
This log will end in daemon.log or journalctl
Comment 5 Jonathan Druart 2016-10-24 13:38:54 UTC
Created attachment 56774 [details] [review]
Bug 17376 - rebuild_zebra.pl in daemon mode no database access kills the process

When running rebuild_zebra.pl in daemon mode, a while loop runs the script for ever.
But if something crashes inside the rebuild process, the all daemon crashes.
For example when it can not access database.
This problem may be temporary so daemon should keep running.

This patch add eval around the rebuild process to allow a run to fail without killing the daemon.
Also moves the DB handler get inside daemon loop because it is broken is DB stoppes.

This is a big issue for indexer running in a systemd service.

Test plan :
- run rebuild_zebra.pl in daemon mode :
/home/koha/src/misc/migration_tools/rebuild_zebra.pl -daemon -z -a -b -x --sleep 30
- stop the database
- wait a minute
=> you see an error on database connexion
=> the daemon is still running
- restart the database
- test the indexer by creating a new record (wait for a minute)

Signed-off-by: Jacek Ablewicz <abl@biblos.pk.edu.pl>

Signed-off-by: Jonathan Druart <jonathan.druart@biblibre.com>
Comment 6 Kyle M Hall 2016-10-28 11:29:17 UTC
Pushed to master for 16.11, thanks Frido!
Comment 7 Frédéric Demians 2016-11-02 18:08:38 UTC
Pushed in 16.05. Will be in 16.05.06.
Comment 8 Julian Maurice 2016-11-08 09:23:50 UTC
Pushed to 3.22.x, will be in 3.22.13