Bug 29697: Don't crash ES reindex if a record is wrong

We don't want rebuild_elasticsearch.pl to crash if a record is wrong
(also fix ktd setup).
Note that now the script will output an error for the problematic
record, which is certainly the expected behaviour as we are doing it
already for authority records.

Signed-off-by: Joonas Kylmälä <joonas.kylmala@iki.fi>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
This commit is contained in:
Jonathan Druart 2022-07-20 09:02:29 +02:00 committed by Tomas Cohen Arazi
parent 25f78370c4
commit cb8aaff8c3
Signed by: tomascohen
GPG key ID: 0A272EA1B2F3C15F

View file

@ -145,12 +145,12 @@ sub get_all_biblios_iterator {
while (1) {
my $row = $rs->next();
return if !$row;
my $marc = $row->metadata->record({ embed_items => 1 });
my $next = eval {
my $marc = $row->metadata->record({ embed_items => 1 });
$class->new($marc, $row->biblionumber);
};
if ($@) {
warn "Something went wrong reading record for biblio $row->biblionumber: $@\n";
warn sprintf "Something went wrong reading record for biblio %s: %s\n", $row->biblionumber, $@;
next;
}
return $next;