I assume that you have one topic and one partition with a replication rate of 2. Which is not a good configuration for optimal performance by Kafka and consumers.
Your logs are not clear enough for a leader switch. The main problem in your topic can be only one leader because of a single section. Now one file in your logs is increasing every day. Kafka internally performs balancing at a certain level (details not confirmed). This may be the reason your leader is moving. But I'm not sure.
Also in your second line of the magazine it says that some of the magazines are truncated. Can you please look through the logs and see if this happens only after truncation?
As already mentioned, you have already checked the Kafka log directory files and their size. Please run the description when you have this problem. The leader switch will also be displayed here. Or, if you can customize some control panel that displays the leader last time. Then it will be easy for you to find the root cause.
bin/kafka-topics.sh
Suggestion: I suggest you create a new topic with a large number of sections (read the Kafka documentation to get an idea of ββthe optimal number of sections) and start writing on it. Or you can check how to change sections for the current topic.
The last thing: does the leader switch cause some problems in your Clients or are you only worried about warnings?
Garry
source share