[ 
https://issues.apache.org/jira/browse/CAMEL-23459?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Andrea Cosentino updated CAMEL-23459:
-------------------------------------
    Fix Version/s: 4.21.0

> camel-docling: Add TTL cleanup for pending async tasks to prevent memory leak
> -----------------------------------------------------------------------------
>
>                 Key: CAMEL-23459
>                 URL: https://issues.apache.org/jira/browse/CAMEL-23459
>             Project: Camel
>          Issue Type: Improvement
>          Components: camel-docling
>            Reporter: Andrea Cosentino
>            Assignee: Andrea Cosentino
>            Priority: Major
>             Fix For: 4.21.0
>
>
> {{DoclingComponent}} tracks pending async-conversion task ids in an in-memory 
> {{ConcurrentHashMap}} that is shared across all producer instances. Entries 
> are added when {{SUBMIT_ASYNC_CONVERSION}} returns and consumed when 
> {{CHECK_CONVERSION_STATUS}} reports a terminal state. There is no expiration 
> mechanism for entries that are never consumed (e.g., the route that submitted 
> the task crashes, the user simply forgets, the docling-serve task never 
> completes).
> h3. Risk
> A long-running Camel application that uses async conversions will accumulate 
> entries in this map indefinitely, leaking memory.
> h3. Proposed change
> * Track a creation timestamp alongside each task id
> * Add a configurable TTL on {{DoclingComponent}} (e.g., {{asyncTaskTtl}} with 
> a sensible default such as 24 hours)
> * Run a scheduled cleanup task that evicts entries older than the TTL
> * Optionally expose a metric for the current size of the map
> h3. Acceptance criteria
> * New {{asyncTaskTtl}} configuration option on {{DoclingComponent}}, 
> defaulting to a reasonable value
> * Background thread (using Camel's {{ScheduledExecutorService}} 
> infrastructure) evicts expired entries
> * Eviction is logged at DEBUG with task id and age
> * Unit test verifies eviction after the configured TTL
> * {{docling-component.adoc}} documents the option and the rationale



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to