Open sgaragan opened 1 month ago
I think you're right in this one, and could explain why we observed some weird behavior before. I would probably go for even slightly different approach, and not handling the transitions explicitly, something as defined by https://kafka.apache.org/38/documentation/streams/tutorial .
// attach shutdown handler to catch control-c
Runtime.getRuntime().addShutdownHook(new Thread("streams-shutdown-hook") {
@Override
public void run() {
streams.close();
latch.countDown();
}
});
try {
streams.start();
latch.await();
} catch (Throwable e) {
System.exit(1);
}
System.exit(0);
Let me know if the new PR works better, I don't have the capability to fully test it at the moment
We hit an issue where we sometimes see the following message although Candyfloss does not stop logging
Looking at the code, it seems that the state change listener looks for a change from RUNNING to !RUNNING which causes the latch to decrement and allows the runKafkaStreams() method call to return. However, if rebalancing occurs for whatever reason, a state which can return to a RUNNING state, then this will shutdown the processing, which seems to happen when using a larger number of threads. For some reason, Candyfloss keeps running though and it looks like it is still processing messages when in reality, the lag continues to grow
The code in question is in CandyflossStreamsApplication
The code should allow for a REBALANCING state but a change to PENDING_SHUTDOWN, ERROR or NOT_RUNNING should result in Candyfloss shutting down
KafkaStreams state diagram