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

Claus Ibsen resolved CAMEL-27584.
---------------------------------
    Resolution: Fixed

Fixed by https://github.com/apache/camel/pull/30910 (merged as 5593d91a1638) 
for 4.24.0.

_Claude Code on behalf of Claus Ibsen_

> camel-file - idempotent read lock: with readLockIdempotentReleaseAsync and a 
> delay over 30 seconds, a release pending at stop is dropped and the file is 
> never picked up again
> ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
>
>                 Key: CAMEL-27584
>                 URL: https://issues.apache.org/jira/browse/CAMEL-27584
>             Project: Camel
>          Issue Type: Bug
>          Components: camel-file
>            Reporter: shashank
>            Assignee: shashank
>            Priority: Major
>             Fix For: 4.24.0
>
>
> h3. What happens
> With {{readLock=idempotent}} or {{idempotent-changed}}, 
> {{readLockIdempotentReleaseAsync=true}} and a 
> {{readLockIdempotentReleaseDelay}}, the read lock releases a file (removes or 
> confirms its key in the idempotent repository) on a scheduled thread pool 
> after the delay. When the consumer stops, the read lock shuts that pool down 
> with {{shutdownGraceful(pool, 30000)}}: it waits up to 30 seconds, then calls 
> {{shutdownNow()}}, which drops the tasks still waiting and nobody runs them.
> So with a delay longer than 30 seconds, a release pending at stop is lost. 
> After a rollback (with the default {{readLockRemoveOnRollback=true}}) the key 
> stays in the repository: after the route is started again, every poll is 
> refused the read lock and the file is never processed. With a persistent or 
> clustered repository (what this read lock is meant for) that lasts until 
> someone deletes the key by hand, with the in-memory one until the JVM 
> restarts. With {{readLockRemoveOnCommit=true}} the key of a committed file 
> stays, so a new file with the same name is never picked up. And any graceful 
> stop with a release pending blocks until the release is due, at most 30 
> seconds.
> h3. How to reproduce
> A file consumer with 
> {{readLock=idempotent&readLockIdempotentReleaseAsync=true&readLockIdempotentReleaseDelay=120000}},
>  a {{MemoryIdempotentRepository}} and a route that fails on the first file. 
> After the failure, stop the route: the stop takes 30 seconds and the key is 
> still in the repository. Start the route again: the file is never consumed 
> (it stays in the directory, its key in the repository). With a 1500 ms delay 
> the stop waits for the release and the file is retried after the restart.
> Found with a TLA+ model of several nodes sharing a directory and an 
> idempotent repository (release delay, stops and restarts, repository 
> failures).
> h3. Fix
> When the read lock stops, it runs the releases still waiting for their delay 
> at once, in the stopping thread, and then shuts the pool down (which no 
> longer has delayed tasks to wait for). A release runs only once, in the pool 
> or at stop. The delay exists to keep a committed file locked a little longer 
> so another node with an old listing does not pick it up; at stop, releasing 
> at once is what lets the file be retried, and dropping the release left the 
> key for good.
> Related, in the same classes: with {{idempotent-changed}} and 
> {{idempotent-rename}}, the read lock records that it owns the key only after 
> the changed or rename check. If that check throws, or the removal of the key 
> after a failed check throws (a repository error), the abort that follows does 
> not remove the key, so the file is never processed again. The read lock now 
> records that it owns the key right after adding it, so the abort removes it.
> _Filed with Claude Code on behalf of allthingssecurity._



--
This message was sent by Atlassian Jira
(v10.3.26#10030026)

Reply via email to