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

Issue with consumer close() in finally block with 'enable.auto.commit=true'

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Open
    • Priority: Minor
    • Resolution: Unresolved
    • Affects Version/s: 0.9.0.0, 0.9.0.1
    • Fix Version/s: None
    • Component/s: consumer
    • Labels:
      None

      Description

      imagine you have a run loop that looks like the following:

        public void run() {
          try {
            consumer.subscribe(topics);
      
            while (true) {
              ConsumerRecords<K, V> records = consumer.poll(Long.MAX_VALUE);
              records.forEach(record -> process(record));
            }
          } catch (WakeupException e) {
            // ignore, we're closing
          } catch (Exception e) {
            log.error("Unexpected error", e);
          } finally {
            consumer.close();
          }
        }
      

      if you run this with 'enable.auto.commit=true' and throw an exception in the 'process()' method you will still try to commit all the read, but unprocessed, offsets in the most recent batch.

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                hachikuji Jason Gustafson
                Reporter:
                norwood dan norwood
              • Votes:
                1 Vote for this issue
                Watchers:
                10 Start watching this issue

                Dates

                • Created:
                  Updated: