Bug 42669: Use exception type check for NoNodes and don't mask real failures
Two follow-up fixes from QA review of the previous commit:
- Detect Search::Elasticsearch::Error::NoNodes via ref($_) rather than
regex-matching the stringified exception, matching the existing
pattern already used in about.pl.
- Only reset jobs to 'new' for retry when NoNodes is the sole problem.
If a genuine indexing error also occurred in the same batch, record
the batch as 'failed' instead of silently discarding that error via
the NoNodes retry path.
Signed-off-by: Lisette Scheer <lisette@bywatersolutions.com>
Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
(cherry picked from commit 246d62da90)
Signed-off-by: Baptiste Wojtkowski <baptiste.wojtkowski@biblibre.com>
This commit is contained in:
parent
245c0b0053
commit
1924b51f6a
|
|
@ -253,7 +253,7 @@ sub commit {
|
|||
$auth_indexer->update_index( \@auth_chunk );
|
||||
} catch {
|
||||
$logger->warn( sprintf "Update of elastic index failed with: %s", $_ );
|
||||
if ( "$_" =~ /NoNodes/ ) {
|
||||
if ( ref($_) eq 'Search::Elasticsearch::Error::NoNodes' ) {
|
||||
$no_nodes = 1;
|
||||
$auth_indexer =
|
||||
Koha::SearchEngine::Indexer->new( { index => $Koha::SearchEngine::AUTHORITIES_INDEX } );
|
||||
|
|
@ -270,7 +270,7 @@ sub commit {
|
|||
$biblio_indexer->update_index( \@bib_chunk );
|
||||
} catch {
|
||||
$logger->warn( sprintf "Update of elastic index failed with: %s", $_ );
|
||||
if ( "$_" =~ /NoNodes/ ) {
|
||||
if ( ref($_) eq 'Search::Elasticsearch::Error::NoNodes' ) {
|
||||
$no_nodes = 1;
|
||||
$biblio_indexer =
|
||||
Koha::SearchEngine::Indexer->new( { index => $Koha::SearchEngine::BIBLIOS_INDEX } );
|
||||
|
|
@ -281,9 +281,11 @@ sub commit {
|
|||
}
|
||||
}
|
||||
|
||||
if ($no_nodes) {
|
||||
if ( $no_nodes && $index_ok ) {
|
||||
|
||||
# ES is unreachable — reset jobs to 'new' so they are retried after reconnection
|
||||
# ES is unreachable, and no other error occurred — reset jobs to 'new' so they are retried
|
||||
# after reconnection. If a genuine indexing error also occurred, fall through to record
|
||||
# the batch as 'failed' instead, so that error isn't masked by the retry.
|
||||
$logger->warn("Elasticsearch unavailable (NoNodes), resetting jobs for retry");
|
||||
$jobs->update(
|
||||
{
|
||||
|
|
|
|||
Loading…
Reference in New Issue