Problem:
The client requested assistance with a Kafka Connect sink connector. The connector was experiencing a lag where it was not reading any records, and the offset was not being committed, causing the lag to keep increasing.
The client indicated that the Kafka Connect connector appears to be stuck and has failed. The following exception was observed in the Connect pods:
ERROR Commit of offsets threw an unexpected exception for sequence number 1. Offset commit cannot be completed since the consumer is not part of an active group for auto partition assignment; it is likely that the consumer was kicked out of the group.
Process:
Step 1 – Initial investigation:
After initial investigation and troubleshooting of the client’s request, the team provided the following analysis:
- The team recommended reducing the poll size as an initial remediation. They suggested examining the consumer code for bugs that could impact processing time.
- An analysis of the logs revealed that the sink connector encountered errors while committing its offset, as it was no longer a member of the group.
- The client could lose group membership if a heartbeat signal was not sent to the queue within the session timeout interval.
- To mitigate this issue, they proposed:
- Increasing the session timeout parameter.
- Decreasing the maximum number of poll records to ensure processing within the timeout.
- Examining the consumer code for bugs causing long processing times, which might prevent the heartbeat signal from being sent.
- For quick resolution, the team recommended halving the maximum number of poll records initially, running the system again to check for error recurrence, with further reductions as needed.
- For long-term functionality, the team suggested examining the client’s code for bugs that could cause significantly longer processing times for certain messages read from the queue.
Parameter Names: max.poll.records session.timeout.ms
Step 2 – Extended troubleshooting:
As the connector still failed to read records after the parameter changes, the team continued the analysis:
- The logs showed frequent consumer group disconnections and timeout errors caused by slow message processing.
- Consumers appeared in the group intermittently without actually consuming messages. Possible causes included slow consumer processing, resource constraints, or network issues.
- Cloud provider metrics showed no critical resource issues.
- The team recommended enabling debug logging before changing parameters further, and monitoring resource usage and network throughput.
Step 3 – Further investigation:
The debug logs from the Connect workers showed that the heartbeat for the sink connector was sent correctly every 3 seconds, as indicated by multiple ‘Sending Heartbeat request…’ and ‘Received successful Heartbeat response…’ entries.
Solution:
To resolve the issue with the sink connector not reading records and failing to commit offsets, the team recommended reducing the maximum number of poll records, for example halving it initially. They also suggested increasing the session timeout parameter and examining the consumer code for bugs causing slow processing, which might disrupt the heartbeat signal. Additionally, enabling verbose logging and monitoring the system’s performance were advised to identify and address underlying causes, ensuring both immediate resolution and long-term stability.
Conclusion:
The issue with the sink connector stemmed from the consumer’s failure to read records and commit offsets, resulting in increasing lag and an unexpected exception due to lost group membership. The team’s initial recommendations included reducing the poll size, adjusting the session timeout, and examining the consumer code for potential bugs. Despite proper heartbeat signals every 3 seconds, the consumer still faced disconnections, suggesting that slow processing or other factors might be causing the issue. Further analysis and adjustments to parameters and code were proposed for both immediate resolution and long-term stability.