shashank created CAMEL-27320:
--------------------------------

             Summary: camel-file - the idempotent read locks release another 
key when the route changes CamelFileName, so a rolled back file is never picked 
up again
                 Key: CAMEL-27320
                 URL: https://issues.apache.org/jira/browse/CAMEL-27320
             Project: Camel
          Issue Type: Bug
          Components: camel-file
            Reporter: shashank
            Assignee: shashank


h3. What happens

With {{readLock=idempotent}}, {{idempotent-changed}} or {{idempotent-rename}} 
and an {{idempotentKey}}, the read lock evaluates the {{idempotentKey}} again 
at commit, rollback and abort ({{asKey}}), on a dummy exchange that copies the 
headers of the routed exchange ({{GenericFileHelper.createDummy}}). The file 
expressions read {{CamelFileName}}, which routes set before a file producer. 
The read lock then releases another key than the one it acquired:

* rollback with the default {{readLockRemoveOnRollback=true}}: the acquired key 
stays in the repository, and the file stays in the inbox and is never picked up 
again by any node (also after a restart with a persistent repository);
* commit with {{readLockRemoveOnCommit=true}}: the commit removes the key the 
new name evaluates to, which can be the key of a file another node is 
processing; that file can then be processed by two nodes at the same time, and 
the own key is left behind.

{{GenericFileConsumer}} already keeps its {{idempotent=true}} key on the 
exchange ({{CamelFileIdempotentKey}}) for this reason. CAMEL-24093 fixed a 
similar mismatch for {{preMove}}.

h3. How to reproduce

{{from("file:inbox?readLock=idempotent&idempotentRepository=#repo&idempotentKey=${file:name}").setHeader("CamelFileName",
 simple("out-${file:name}"))}} and then a failure: the file is attempted once 
and never again, and the repository keeps its key.

Found with a TLA+ model of clustered consumption with an idempotent read lock.

h3. Fix

Keep the key computed at acquire on the exchange and release that key at 
commit, rollback and abort, in the three strategies.

_Filed with Claude Code on behalf of allthingssecurity._



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

Reply via email to