Claus Ibsen created CAMEL-27550:
-----------------------------------
Summary: camel-kafka - KafkaIdempotentRepository and
KafkaKeyValueRepository: order the remaining changelog cases (unknown send
outcome, clear, key-value repository)
Key: CAMEL-27550
URL: https://issues.apache.org/jira/browse/CAMEL-27550
Project: Camel
Issue Type: Improvement
Components: camel-kafka
Reporter: Claus Ibsen
Fix For: 4.25.0
Follow-up of CAMEL-27432 (PR https://github.com/apache/camel/pull/30794), which
orders the records read by the background poller of
{{KafkaIdempotentRepository}} against the local add and remove of the same key.
Three cases were left out of that PR:
h3. 1. An add whose send has an unknown outcome
When the send of an {{add}} fails without telling whether the record was
written (a delivery timeout, or an interrupt while waiting), {{add}} rolls back
the local cache and throws. If the broker wrote the record after all, every
instance applies it, and every later start replays it, so every later copy of
the message is rejected everywhere.
CAMEL-27432 proposed this: after such a failure, write a {{remove}} of the key
and wait for it before {{add}} throws, holding the key until then. Do not send
the {{remove}} under the lock of the repository, because the producer can block
for up to {{max.block.ms}}. An {{add}} could then take up to
{{delivery.timeout.ms}} longer to fail. This is best effort.
h3. 2. clear() is not ordered against the keys
A {{clear}} record that the poller reads after a newer local {{add}} wipes that
key. With one partition, the clear could keep the keys whose local write is
newer than its offset, or still in flight. With more than one partition the two
cannot be ordered, and the docs recommend one partition.
h3. 3. KafkaKeyValueRepository has the same order problem
{{KafkaKeyValueRepository}} uses the same {{KafkaChangelog}}, so an older
record of a key can undo a newer local put or remove. The approach of
CAMEL-27432 (track the offset of each local write until the poller reads it
back) applies here too.
_Filed with Claude Code on behalf of Claus Ibsen (davsclaus)_
--
This message was sent by Atlassian Jira
(v10.3.26#10030026)