Bug 14993 - rebuild_zebra.pl, when recreating Zebra-directory structure, mkdir doesn't fail/error/die
Summary: rebuild_zebra.pl, when recreating Zebra-directory structure, mkdir doesn't fa...
Status: Failed QA
Alias: None
Product: Koha
Classification: Unclassified
Component: Searching (show other bugs)
Version: Main
Hardware: All All
: P5 - low enhancement (vote)
Assignee: Olli-Antti Kivilahti
QA Contact: Testopia
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-10-09 10:19 UTC by Olli-Antti Kivilahti
Modified: 2016-03-24 19:11 UTC (History)
3 users (show)

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


Attachments
Bug 14993 - rebuild_zebra.pl, when recreating Zebra-directory structure, mkdir doesn't fail/error/die (1.78 KB, patch)
2015-10-09 10:19 UTC, Olli-Antti Kivilahti
Details | Diff | Splinter Review

Note You need to log in before you can comment on or make changes to this bug.
Description Olli-Antti Kivilahti 2015-10-09 10:19:23 UTC
This is due to implicit perl programming.
Avoid doing this!
    mkdir $bdir || die "Error $!";

TO REPLICATE:

1. rm -r /home/koha/koha-dev/var/lib/zebradb (or whatever your zebradb location is)
2. run rebuild_zebra.pl -b -a -r -x -v
3. Observe how rebuild_zebra.pl tells that it has rebuilt all the missing
   directories.
4. cd /home/koha/koha-dev/var/lib/zebradb/biblios
5. No such directory???
6. You wait for several hours to reindex your zebradb to find that nothing
   works :(

AFTER THIS PATCH:

1. rm -r /home/koha/koha-dev/var/lib/zebradb (or whatever your zebradb location is)
2. run rebuild_zebra.pl -b -a -r -x -v
3. Observe how rebuild_zebra.pl tells that it couldn't create missing directories.

A (possibly) better fix would be to recreate the top two directories from the
path, but no point patching a dead horse, since ElasticSearch will be here soon :)
Comment 1 Olli-Antti Kivilahti 2015-10-09 10:19:46 UTC
Created attachment 43293 [details] [review]
Bug 14993 - rebuild_zebra.pl, when recreating Zebra-directory structure, mkdir doesn't fail/error/die

This is due to implicit perl programming.
Avoid doing this!
    mkdir $bdir || die "Error $!";

TO REPLICATE:

1. rm -r /home/koha/koha-dev/var/lib/zebradb (or whatever your zebradb location is)
2. run rebuild_zebra.pl -b -a -r -x -v
3. Observe how rebuild_zebra.pl tells that it has rebuilt all the missing
   directories.
4. cd /home/koha/koha-dev/var/lib/zebradb/biblios
5. No such directory???
6. You wait for several hours to reindex your zebradb to find that nothing
   works :(

AFTER THIS PATCH:

1. rm -r /home/koha/koha-dev/var/lib/zebradb (or whatever your zebradb location is)
2. run rebuild_zebra.pl -b -a -r -x -v
3. Observe how rebuild_zebra.pl tells that it couldn't create missing directories.

A (possibly) better fix would be to recreate the top two directories from the
path, but no point patching a dead horse, since ElasticSearch will be here soon :)
Comment 2 Mark Tompsett 2015-10-09 18:29:40 UTC
Comment on attachment 43293 [details] [review]
Bug 14993 - rebuild_zebra.pl, when recreating Zebra-directory structure, mkdir doesn't fail/error/die

Review of attachment 43293 [details] [review]:
-----------------------------------------------------------------

::: misc/migration_tools/rebuild_zebra.pl
@@ -305,4 @@
>          my $bdir = $base . $dir;
>          if (! -d $bdir) {
>              $needed_repairing = 1;
> -            mkdir $bdir || die "Unable to create '$bdir': $!\n";

oh my! What a nasty glob'ing issue. Thanks for this fix.
Comment 3 I'm just a bot 2016-03-06 21:55:02 UTC
Applying: Bug 14993 - rebuild_zebra.pl, when recreating Zebra-directory structure, mkdir doesn't fail/error/die
Comment 4 Mirko Tietgen 2016-03-24 19:11:51 UTC
Zebra is not going away any time soon. ES is not going to be a replacement, but an alternative, at least for the foreseeable future.

If this is being touched, it should fix the problem by creating the folders instead of failing because they are missing.