79295738

Date: 2024-12-19 22:30:35
Score: 3.5
Natty:
Report link

Could you provide the log entries which shows that messages are missed?

It seems that the consumer commits the current offset, and then logs that it has consumed a message from the partition.

What could be happening is that after committing, the pod is terminated by (lets say) Kubernetes without giving your program enough time to finish logging out that it has consumed the message.

You can configure terminationGracePeriodSeconds as part of your pod deployment specification.

As part of your python program, you can also capture the SIGTERM event when your pod is asked to stop.

signal.signal(signal.SIGTERM, graceful_shutdown)

graceful_shutdown would be a method which would instruct your consumer handle any current messages it has received from kafka, commit it's offsets back, log out that it has handled those messages, and finally, gracefully stop the kafka consumer.

At that point it can then exit cleanly.

Reasons:
  • Blacklisted phrase (1): What could be
  • RegEx Blacklisted phrase (2.5): Could you provide
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Contains question mark (0.5):
  • Low reputation (0.5):
Posted by: John