Bug 15188 - remove_unused_authorities.pl will delete all authorities if zebra is not running
Summary: remove_unused_authorities.pl will delete all authorities if zebra is not running
Status: CLOSED FIXED
Alias: None
Product: Koha
Classification: Unclassified
Component: MARC Authority data support (show other bugs)
Version: Main
Hardware: All All
: P5 - low major
Assignee: Alex Arnaud
QA Contact: Testopia
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-11-13 16:26 UTC by Matthias Meusburger
Modified: 2019-06-27 09:24 UTC (History)
7 users (show)

See Also:
Change sponsored?: ---
Patch complexity: ---
Documentation contact:
Documentation submission:
Text to go in the release notes:
Version(s) released in:
Circulation function:


Attachments
Bug 15188 - remove_unused_authorities.pl exit if all authorities should be deleted (2.00 KB, patch)
2015-12-01 11:00 UTC, Alex Arnaud
Details | Diff | Splinter Review
Bug 15188 - remove_unused_authorities.pl dies if zebra server is not running (940 bytes, patch)
2015-12-29 15:47 UTC, Alex Arnaud
Details | Diff | Splinter Review
Bug 15188 - Fixes remove_unused_authorities.pl will delete all authorities if zebra is not running (1.37 KB, patch)
2016-01-16 02:21 UTC, Chris Cormack
Details | Diff | Splinter Review
Bug 15188 - Fixes remove_unused_authorities.pl will delete all authorities if zebra is not running (1.44 KB, patch)
2016-01-19 08:58 UTC, Jonathan Druart
Details | Diff | Splinter Review
Bug 15188: Do not remove unused auths if zebra is not reachable (1.22 KB, patch)
2016-01-19 08:58 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 Matthias Meusburger 2015-11-13 16:26:31 UTC
The script misc/migration_tools/remove_unused_authorities.pl will delete all authorities if zebra is not running.

Test plan:

1) Shut down zebra: koha-zebra-ctl.sh stop

2) Execute the script: remove_unused_authorities.pl (with -t if you don't want to really delete from your database).

3) Check that the script would have deleted all the authorities (eg: 31449 authorities parsed, 31449 deleted and 0 unchanged because used).
Comment 1 Alex Arnaud 2015-12-01 11:00:44 UTC Comment hidden (obsolete)
Comment 2 Alex Arnaud 2015-12-01 11:07:15 UTC
It looks like ZOOM module behaves like connection was established when zebra is not running (No error code, no error message or exception).

I have libnet-z3950-zoom-perl 1.26 on debian wheezy. It would be interesting to test with version 1.30 (jessie package) but for wheezy i think the best fix is to ensure that all authorities will not be deleted.
Comment 3 Jonathan Druart 2015-12-28 11:07:22 UTC
Why don't you just check that the zebra daemon is running?
Comment 4 Jonathan Druart 2015-12-28 11:14:51 UTC
Same behavior with 1.30
Comment 5 Alex Arnaud 2015-12-28 14:22:55 UTC
(In reply to Jonathan Druart from comment #3)
> Why don't you just check that the zebra daemon is running?

Because:
- it would depend on system command to get the pid that could not be installed.
- the daemon could run on a remote server.
- also, it seems that we have the same problem if zebra is running with nothing indexed.
Comment 6 Jonathan Druart 2015-12-28 15:10:21 UTC
Have a look at about.pl
 94 my $errZebraConnection = C4::Context->Zconn("biblioserver",0)->errcode();

This could do the trick correctly.
Comment 7 Alex Arnaud 2015-12-29 15:47:15 UTC Comment hidden (obsolete)
Comment 8 Alex Arnaud 2015-12-29 15:48:36 UTC
(In reply to Jonathan Druart from comment #6)
> Have a look at about.pl
>  94 my $errZebraConnection = C4::Context->Zconn("biblioserver",0)->errcode();
> 
> This could do the trick correctly.

My apologies
Comment 9 Chris Cormack 2016-01-16 02:21:04 UTC Comment hidden (obsolete)
Comment 10 Jonathan Druart 2016-01-19 08:58:18 UTC
Created attachment 46849 [details] [review]
Bug 15188 - Fixes remove_unused_authorities.pl will delete all authorities if zebra is not running

Test plan:

1) Shut down zebra: koha-zebra-ctl.sh stop
2) Execute the script: remove_unused_authorities.pl (with -t if you don't want to really delete from your database).
3) Check that the script would have deleted all the authorities (eg: 31449 authorities parsed, 31449 deleted and 0 unchanged because used).
4) Apply patch
5) Run, notice that the script dies because zebra is unavailable

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

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Comment 11 Jonathan Druart 2016-01-19 08:58:21 UTC
Created attachment 46850 [details] [review]
Bug 15188: Do not remove unused auths if zebra is not reachable

Other conn errors should be checked (wrong user/pwd, etc.)

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Comment 12 Brendan Gallagher 2016-01-27 01:04:01 UTC
Pushed to Master - Should be in the May 2016 release.  Thanks!
Comment 13 Julian Maurice 2016-01-27 14:32:22 UTC
Patches pushed to 3.22.x, will be in 3.22.3
Comment 14 Frédéric Demians 2016-02-12 06:34:44 UTC
This patch has been pushed to 3.20.x, will be in 3.20.9.