[Bug 44024] New: es_indexer_daemon.pl: keep the batch and retry while Elasticsearch is unreachable, jobs are lost with STOMP
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=44024 Bug ID: 44024 Summary: es_indexer_daemon.pl: keep the batch and retry while Elasticsearch is unreachable, jobs are lost with STOMP Initiative type: --- Sponsorship --- status: Product: Koha Version: Main Hardware: All OS: All Status: NEW Severity: normal Priority: P5 - low Component: Searching - Elasticsearch Assignee: koha-bugs@lists.koha-community.org Reporter: johan@imcode.com QA Contact: testopia@bugs.koha-community.org Target Milestone: --- When Elasticsearch cannot be reached, es_indexer_daemon.pl either marks the index jobs 'failed' (see bug 44023) or, once that is fixed, resets them to 'new' (bug 42669). Neither recovers with JobsNotificationMethod = STOMP, which is the default: the message is acknowledged before commit() runs, and the daemon only reads the background_jobs table in polling mode, so a job reset to 'new' is never picked up again and the update is lost. Tested with bug 44023 applied and STOMP: Elasticsearch stopped, a job enqueued, job reset to 'new', Elasticsearch started again: two minutes later the job is still 'new'. With polling the same job finishes. The patch keeps the batch in the forked worker that already owns it and retries it every ES_RETRY_DELAY seconds (default 10), for at most ES_RETRY_MAX_WAIT seconds (default 3600). The jobs stay 'started' while waiting and finish as soon as Elasticsearch answers. After ES_RETRY_MAX_WAIT they are marked 'failed', like any indexing error. SIGTERM, SIGINT, or the parent daemon disappearing while waiting marks the jobs 'failed' and the worker exits. This works for STOMP and polling, and does not depend on the polling change in bug 43729. Errors are classified by is_connection_error(): NoNodes, Timeout, Cxn and Unavailable, plus transport failures reported with the pseudo status 599 (HTTP::Tiny), which Search::Elasticsearch reports as type Request when an open connection is reset. Real indexing errors still mark the jobs 'failed'. The indexing of a batch moves to index_batch() so it can be called again. This overlaps with bug 43569, which changes the same lines of the daemon; the conflict is mechanical. Depends on bug 44022: without it a worker that has seen one failed request rejects every healthy response afterwards and never recovers. Tested with the daemon from main and a real STOMP broker (ktd): outage -> the job stays 'started' and finishes after Elasticsearch is back; ES_RETRY_MAX_WAIT reached -> 'failed'; SIGTERM to the worker, or only to the parent -> 'failed' and the worker exits. Not tested: authority batches. -- You are receiving this mail because: You are the assignee for the bug. You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=44024 Johan Larsson <johan@imcode.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Depends on| |44022, 44023 See Also| |https://bugs.koha-community | |.org/bugzilla3/show_bug.cgi | |?id=42669 Referenced Bugs: https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=44022 [Bug 44022] Elasticsearch: product check workaround is never restored, one failed request breaks the client for the rest of the process https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=44023 [Bug 44023] es_indexer_daemon.pl never recognises NoNodes: the check added in bug 42669 can never match -- You are receiving this mail because: You are the assignee for the bug. You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=44024 Johan Larsson <johan@imcode.com> changed: What |Removed |Added ---------------------------------------------------------------------------- See Also| |https://bugs.koha-community | |.org/bugzilla3/show_bug.cgi | |?id=43569 -- You are receiving this mail because: You are watching all bug changes. You are the assignee for the bug.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=44024 Johan Larsson <johan@imcode.com> changed: What |Removed |Added ---------------------------------------------------------------------------- See Also| |https://bugs.koha-community | |.org/bugzilla3/show_bug.cgi | |?id=43729 -- You are receiving this mail because: You are watching all bug changes. You are the assignee for the bug.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=44024 --- Comment #1 from Johan Larsson <johan@imcode.com> --- Created attachment 210828 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=210828&action=edit Bug 44024: es_indexer_daemon.pl: retry the batch while Elasticsearch is unreachable When Elasticsearch cannot be reached, commit() hands the jobs back to the queue (status 'new') and returns. That cannot work for the background jobs queue in general: - with JobsNotificationMethod = STOMP the broker message has already been acknowledged before commit() runs, and the daemon only reads the background_jobs table in polling mode, so a job reset to 'new' is never picked up again; - the batch is dropped from the worker, so nothing is retried until something else notices the 'new' job. Instead keep the batch in the forked worker that already owns it and retry it every ES_RETRY_DELAY seconds (default 10) for at most ES_RETRY_MAX_WAIT seconds (default 3600). The jobs stay 'started' while waiting, and finish as soon as Elasticsearch answers. After ES_RETRY_MAX_WAIT they are marked 'failed', like any indexing error. A SIGTERM or SIGINT while waiting marks the jobs 'failed' and exits, and so does a worker whose parent daemon has gone (a stop that only signals the parent), instead of waiting on as an orphan. Errors are classified by is_connection_error(): NoNodes, Timeout, Cxn and Unavailable, plus transport failures reported with the pseudo status 599 (HTTP::Tiny), which Search::Elasticsearch reports as type Request when an open connection is reset. Real indexing errors still mark the jobs failed. The indexing of a batch moves to index_batch() so it can be called again. Test plan: 1. Start misc/workers/es_indexer_daemon.pl (polling or STOMP). 2. Stop Elasticsearch. 3. Modify a record so that an indexing job is enqueued. => The job stays 'started'; the worker log shows 'Elasticsearch unavailable, retrying 1 job(s) every 10s'. 4. Start Elasticsearch again. => The log shows 'Elasticsearch reachable again, 1 job(s) indexed after Ns', the job finishes and the record is searchable. 5. Repeat 1-3 and send SIGTERM to the worker. => The job is marked 'failed' and the worker exits. The same happens when only the parent daemon is sent SIGTERM. 6. Repeat 1-3 with ES_RETRY_MAX_WAIT=30. => After 30 seconds the job is marked 'failed'. -- You are receiving this mail because: You are the assignee for the bug. You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=44024 Johan Larsson <johan@imcode.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |Needs Signoff -- You are receiving this mail because: You are the assignee for the bug. You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=44024 Johan Larsson <johan@imcode.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Assignee|koha-bugs@lists.koha-commun |johan@imcode.com |ity.org | -- You are receiving this mail because: You are watching all bug changes. You are the assignee for the bug.
participants (1)
-
bugzilla-daemon@bugs.koha-community.org