Uploaded image for project: 'Kafka'
  1. Kafka
  2. KAFKA-6607

Kafka Streams lag not zero when input topic transactional

    XMLWordPrintableJSON

    Details

    • Type: Improvement
    • Status: Resolved
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 1.0.0
    • Fix Version/s: 2.5.0
    • Component/s: streams
    • Labels:
      None

      Description

      When an input topic for a Kafka Streams application is written using transaction, Kafka Streams commits an "incorrect" offset, ie, it commits "lastProcessedMessageOffset + 1" that is smaller than "endOffset" if it reaches the end of topic. The reason is the commit marker that is the last "message" in the topic; Streams does not take commit markers into account when committing.

      This is not a correctness issue, but when one inspect the consumer lag via bin/kafka-consumer.group.sh the lag is shown as 1 instead of 0 – what is correct from consumer-group tool point of view.

      Note that all applications using a plain consumer may face the same issue if they use `KafkaConsumer#commitSync(Map<TopicPartition, OffsetAndMetadata> offsets)`: to address the issue, the correct pattern is to either commit "nextRecord.offset()" (if the next record is available already, ie, was returned by `poll()`, or use `consumer.position()` that takes the commit marker into account and would "step over it").

        Attachments

          Activity

            People

            • Assignee:
              mjsax Matthias J. Sax
              Reporter:
              mjsax Matthias J. Sax
            • Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: