vilmosnagy opened a new pull request, #30694: URL: https://github.com/apache/camel/pull/30694
# Description [CAMEL-27487](https://issues.apache.org/jira/browse/CAMEL-27487), discussed on the dev list: https://lists.apache.org/thread.html/1npz481szd4c8kg4h9m2v6gcygrzt6hl When a poll of a `ScheduledPollConsumer` throws an `Error` (e.g. an `OutOfMemoryError` or `StackOverflowError` thrown by the route of the polled message, which the error handler does not handle), `run()` logs and rethrows it, and the scheduled task never runs again. The health check did not record the `Error` and stayed UP, so a consumer that had stopped polling looked healthy. With this change: - `doRun` catches the `Error`, records it as a failed poll and rethrows it, so the scheduled task still stops as before. - The first `Error` is kept in a sticky fatal error marker (`ScheduledPollConsumer.getFatalError()`). Only stopping the consumer clears it (e.g. restarting the route). A successful poll does not clear it, and neither does suspend/resume, because neither restarts the dead task. This matters with `scheduler.concurrentConsumers > 1`: the other tasks keep polling successfully while the consumer runs with one task less. - `ScheduledPollConsumerHealthCheck` reports DOWN with the `Error` while the marker is set. - The fatal error log now says that the task stopped polling until the route is restarted. - `isSchedulerStarted()` is unchanged. - Docs: an entry in the 4.24 upgrade guide, and a note in `error-handler.adoc` ("An Error thrown by a processor"). The note says the exchange may stay inflight, so restarting the route waits for the shutdown timeout. This covers `ScheduledPollConsumer` only. Other consumers (e.g. timer, seda) are tracked separately, as discussed on the list. ## Commits (intentionally not squashed) I kept the commits separate on purpose, so the review can go step by step: 1. **Failing tests**: the new tests on top of `main`. All 5 new tests fail there. 2. **Naive fix**: the single-threaded fix that was sent to the mailing list. 3 of the 5 tests pass. The `concurrentConsumers` / later-successful-poll cases still fail. 3. **Multithreaded fix**: the sticky fatal error marker. All tests pass. 4. **Docs**: the upgrade guide and error handler documentation. Feel free to squash on merge. ## Tests - `ScheduledPollConsumerTest`: - an `Error` from `poll()` after successful polls (health check UP before the `Error`, DOWN with the `Error` after it, no rollback of the poll strategy); - a later successful poll keeps it DOWN; - stop/start makes it UP again. - `SchedulerConsumerHealthCheckTest` (real `scheduler` route): - an `OutOfMemoryError` from the route stops polling and the check is DOWN; - it stays DOWN with `scheduler.concurrentConsumers=2` while the other task keeps polling; - a route restart polls again and the check is UP. - Ran all `*ScheduledPoll*` and `*HealthCheck*` tests in camel-core: 55 tests, 0 failures. ## How this was made - A human hit the bug in production: a polling route stopped after an `OutOfMemoryError` while its health check stayed UP. - Claude Code (Anthropic) did the triage. - A human filed the issue on the mailing list with the initial naive, single-threaded fix. - AI (Claude Code) wrote the tests. A human reviewed and approved them. - AI (Claude Code) turned the fix into the multithreaded version and wrote the docs, with a human overseeing. # Target - [x] I checked that the commit is targeting the correct branch (Camel 4 uses the `main` branch) # Tracking - [x] If this is a large change, bug fix, or code improvement, I checked there is a [JIRA issue](https://issues.apache.org/jira/browse/CAMEL) filed for the change (usually before you start working on it). # Apache Camel coding standards and style - [x] I checked that each commit in the pull request has a meaningful subject line and body. - [ ] I have run `mvn clean install -DskipTests` locally from root folder and I have committed all auto-generated changes. (I ran it for the changed modules, `core/camel-support` and `core/camel-core`, with the formatter. I did not run it from the root folder.) # AI-assisted contributions - [x] If this PR includes AI-generated code, commits have proper co-authorship attribution (e.g., `Co-authored-by` trailers) and the PR description identifies the AI tool used. 🤖 Generated with [Claude Code](https://claude.com/claude-code) -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
