GitHub user dguy opened a pull request: https://github.com/apache/kafka/pull/1970
KAFKA-4253: Fix Kafka Stream thread shutting down process ordering Changed the ordering in `StreamThread.shutdown` 1. commitAll (we need to commit so that any cached data is flushed through the topology) 2. close all tasks 3. producer.flush() - so any records produced during close are flushed and we have offsets for them 4. close all state managers 5. close producers/consumers 6. remove the tasks Also in `onPartitionsRevoked` 1. commitAll 2. close all tasks 3. producer.flush 4. close all state managers You can merge this pull request into a Git repository by running: $ git pull https://github.com/dguy/kafka kafka-4253 Alternatively you can review and apply these changes as the patch at: https://github.com/apache/kafka/pull/1970.patch To close this pull request, make a commit to your master/trunk branch with (at least) the following in the commit message: This closes #1970 ---- commit d52e8de5fefac51c9eb59a9c965bc17dcd3aa3bc Author: Damian Guy <damian....@gmail.com> Date: 2016-10-05T10:03:21Z change shutdown order ---- --- If your project is set up for it, you can reply to this email and have your reply appear on GitHub as well. If your project does not have this feature enabled and wishes so, or if the feature is enabled but not working, please contact infrastructure at infrastruct...@apache.org or file a JIRA ticket with INFRA. ---