[
https://issues.apache.org/jira/browse/CAMEL-27487?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18150000#comment-18150000
]
Vilmos Nagy commented on CAMEL-27487:
-------------------------------------
PR with the fix: https://github.com/apache/camel/pull/30694
> ScheduledPollConsumer stops polling after a java.lang.Error, but the route
> stays Started and the health check stays UP
> ----------------------------------------------------------------------------------------------------------------------
>
> Key: CAMEL-27487
> URL: https://issues.apache.org/jira/browse/CAMEL-27487
> Project: Camel
> Issue Type: Bug
> Components: came-core
> Affects Versions: 4.23.0
> Reporter: Vilmos Nagy
> Priority: Major
>
> Description:
> When a {{java.lang.Error}} (OutOfMemoryError, StackOverflowError,
> LinkageError, ...) is thrown on a ScheduledPollConsumer's poll thread, either
> by {{poll()}} or by the route processing the exchange, the consumer stops
> polling for good. Since CAMEL-21769 this is intentional: {{run()}} logs the
> Error and rethrows it, and the JDK {{ScheduledThreadPoolExecutor}} then stops
> rescheduling the task.
> But the stop is not visible:
> * the route still reports Started;
> * {{DefaultScheduledPollConsumerScheduler.isSchedulerStarted()}} still
> returns true, because nothing checks the futures;
> * {{{}errorCounter{}}}/{{{}lastError{}}} are never updated, so
> {{ScheduledPollConsumerHealthCheck}} stays UP.
> We hit this with an aws2-s3 route that threw an OutOfMemoryError while
> processing an exchange. It stopped polling without any signal, and only our
> own monitoring noticed.
> h3. Proposed fix
> * In {{{}ScheduledPollConsumer.doRun(){}}}, catch {{Error}} next to the
> existing {{{}catch (Exception e){}}}, skipping the ExceptionHandler and
> {{{}pollStrategy.rollback(){}}}. Let the existing bookkeeping set
> {{lastError}} and increment {{{}errorCounter{}}}, then rethrow, so the task
> still ends.
> * Keep a sticky marker for the fatal Error that only a stop/start of the
> consumer clears. With {{{}concurrentConsumers > 1{}}}, a successful (or
> greedy) poll on another thread would otherwise reset the counters, and the
> health check would go back to UP with one poller fewer.
> * Make {{ScheduledPollConsumerHealthCheck}} report DOWN while the marker is
> set.
> * Leave {{isSchedulerStarted()}} as it is: {{{}doStop(){}}},
> {{unscheduleTask()}} and {{startScheduler()}} rely on it reflecting the list
> of futures.
> * Make the log line in {{run()}} say that polling has stopped until the
> route is restarted.
> h3. Docs
> * 4.24 upgrade guide: the consumer health check now reports DOWN after an
> Error, where it reported UP before.
> * {{{}error-handler.adoc{}}}, section "An Error thrown by a processor":
> mention this, and note that an OutOfMemoryError or StackOverflowError thrown
> in the route leaves that exchange inflight, so a route restart waits for the
> shutdown timeout.
> h3. Tests
> * Error thrown by {{poll()}}
> * Error thrown by the route
> * {{concurrentConsumers=2}}
> * stop/start of the route polls again, and the health check is UP again
> Discussion: [https://lists.apache.org/thread/1npz481szd4c8kg4h9m2v6gcygrzt6hl]
> Other consumers with the same pattern (timer, seda, ...) are tracked
> separately.
--
This message was sent by Atlassian Jira
(v10.3.26#10030026)