[
https://issues.apache.org/jira/browse/KAFKA-21605?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
TaiJuWu reassigned KAFKA-21605:
-------------------------------
Assignee: TaiJuWu (was: Chia-Ping Tsai)
> Producer state snapshot should recover 5 states
> ------------------------------------------------
>
> Key: KAFKA-21605
> URL: https://issues.apache.org/jira/browse/KAFKA-21605
> Project: Kafka
> Issue Type: Bug
> Reporter: Chia-Ping Tsai
> Assignee: TaiJuWu
> Priority: Minor
>
>
> {code:java}
> public static void writeSnapshot(File file, Map<Long, ProducerStateEntry>
> entries, boolean sync) throws IOException {
> ProducerSnapshot producerSnapshot = new ProducerSnapshot();
> List<ProducerSnapshot.ProducerEntry> producerEntries = new
> ArrayList<>(entries.size());
> for (Map.Entry<Long, ProducerStateEntry> producerIdEntry :
> entries.entrySet()) {
> Long producerId = producerIdEntry.getKey();
> ProducerStateEntry entry = producerIdEntry.getValue();
> ProducerSnapshot.ProducerEntry producerEntry = new
> ProducerSnapshot.ProducerEntry()
> .setProducerId(producerId)
> .setEpoch(entry.producerEpoch())
> .setLastSequence(entry.lastSeq())
> .setLastOffset(entry.lastDataOffset())
> .setOffsetDelta(entry.lastOffsetDelta())
> .setTimestamp(entry.lastTimestamp())
> .setCoordinatorEpoch(entry.coordinatorEpoch())
>
> .setCurrentTxnFirstOffset(entry.currentTxnFirstOffset().orElse(-1L));
> producerEntries.add(producerEntry);
> }
> {code}
> The snapshot only contains the last batch, but the idempotent mechanism
> expects the server to remember the last five. Hence, a server will lose the
> other four once it restarts, and the retry requests will get an out of order
> sequence error.
>
--
This message was sent by Atlassian Jira
(v10.3.26#10030026)