davsclaus opened a new pull request, #30791: URL: https://github.com/apache/camel/pull/30791
_Claude Code on behalf of Claus Ibsen (davsclaus)_ [CAMEL-27430](https://issues.apache.org/jira/browse/CAMEL-27430): `FileIdempotentRepository` rewrote its file store in place whenever a key was removed or the oldest keys were dropped. The store was truncated to 0 bytes first, then written key by key with unbuffered writes and no sync. A remove is a common call, because `removeOnFailure=true` is the default of the Idempotent Consumer, and the file consumer's idempotent read lock removes the key on rollback. When the JVM stopped during the rewrite, or a write failed (disk full, an NFS error), the keys not written yet were lost, and after a restart their messages were processed again. **What changes:** - The rewrite now goes to a temporary file next to the store (`<store>.tmp`). That file gets the store's permissions before any key is written to it and is synced, then it is moved over the store with `ATOMIC_MOVE`, as `FileStateRepository` does since CAMEL-25213 (#27162). For a symlinked store, the real file is replaced and the link is kept. When writing fails, the temporary file is deleted and the store is unchanged. - When the temporary file cannot be created or cannot replace the store, the store is rewritten in place as before. That happens, for example, when the store is a single file mounted into a container (`EBUSY`), or when its directory is read-only. The first time, a WARN explains the risk; later times are logged at DEBUG. - `add` no longer fails when dropping the oldest keys fails: the key is already stored, and failing the add would make the retry look like a duplicate (the case CAMEL-25681 fixed for a failing append). The failure is logged, and the next add tries again. - A key is appended together with its delimiter in one write. **Tests:** the new `FileIdempotentRepositoryRewriteTest` (camel-support) covers: - a remove whose rewrite fails halfway - an add whose drop of the oldest keys fails - the in-place fallback when no temporary file can be created - a symlinked store - the store's permissions while the temporary file is written, and after the rewrite The existing `FileIdempotent*`, `SedaFileIdempotent*` and `FileStateRepositoryTest` tests in camel-support and camel-core pass. 🤖 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]
