[
https://issues.apache.org/jira/browse/CAMEL-27418?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Work on CAMEL-27418 started by shashank.
----------------------------------------
> camel-wal - WriteAheadResumeStrategy.start() truncates the log before the
> carried unconfirmed entries are written again, so a crash, an error or a
> power loss in start() loses them
> -----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
>
> Key: CAMEL-27418
> URL: https://issues.apache.org/jira/browse/CAMEL-27418
> Project: Camel
> Issue Type: Bug
> Reporter: shashank
> Assignee: shashank
> Priority: Minor
>
> h3. What happens
> Since CAMEL-26107, {{WriteAheadResumeStrategy.start()}} reads the log of the
> previous run and keeps its unconfirmed entries in the new log until
> {{loadCache()}} replays them. But {{new LogWriter(...)}} opens the same file
> with {{TRUNCATE_EXISTING}} and writes the header first, and the carried
> entries are appended only after that and forced at the next supervisor tick.
> If the process crashes in that window, if {{start()}} throws there (the flush
> task is rejected, an append fails with an {{IOException}}), or if the power
> fails before the next tick, the log is left empty. The next start replays
> nothing, and the consumer resumes from an older offset and processes those
> messages again.
> h3. How to reproduce
> Run 1 appends offset 1 of key A, which the wrapped strategy does not confirm,
> and stops. Run 2: {{start()}} fails because the executor rejects the flush
> task. Run 3 replays nothing (expected A=1). Also reproduced with real process
> crashes ({{Runtime.halt}} in child JVMs). Found with a TLA+ model.
> h3. Fix
> With entries to carry, the {{LogWriter}} writes the header and the entries to
> {{<log>.tmp}} in the same directory, forces it, moves it atomically over the
> log ({{ATOMIC_MOVE}}, no non-atomic move), forces the directory where
> possible, and then schedules the flush task. Where the log cannot be replaced
> atomically (no permission to create the file in the directory, a log file
> mounted on its own into a container, no atomic rename), a WARN is logged and
> the log is rewritten in place as before, but forced right after the carried
> entries, before the flush task is scheduled, so {{start()}} does not fail
> where it started before. Without entries the log is truncated in place as
> before. 4.24 upgrade guide paragraph.
> Minor: it needs a second failure inside {{start()}}, and the effect is
> messages processed again, not lost.
> _Filed with Claude Code on behalf of allthingssecurity._
--
This message was sent by Atlassian Jira
(v10.3.26#10030026)