ruby-kafka icon indicating copy to clipboard operation
ruby-kafka copied to clipboard

Recover from Kafka::MessageSizeTooLarge exception in async producer.

Open RyanAmos opened this issue 3 years ago • 2 comments

You can get into a bad unrecoverable state when a Kafka::MessageSizeTooLarge exception is raised.

When we receive this exception, if we're using the sync producer, then we simply re-raise this exception. If we're using the async producer, then we attempt to remove the largest message from the buffer and simply retry. Once retried, if the buffer is still too large, we'll continue removing the largest message until we can successfully flush the buffer.

This will re-raise the exception since it is done synchronously:

DeliveryBoy.deliver('a' * 1_500_000, topic: 'test')

This will remove the largest message and continue to retry:

DeliveryBoy.deliver_async('a' * 1_500_000, topic: 'test')

Would love to get some feedback on this approach. Specifically @dasch since you had some opinions on the approach here: https://github.com/zendesk/ruby-kafka/pull/358

RyanAmos avatar Jul 09 '20 00:07 RyanAmos

Excited for this - it's been bothering me for a while!

dorner avatar Jul 20 '20 17:07 dorner

Also, ❤️

dasch avatar Aug 03 '20 12:08 dasch

Pull request has been marked as stale due to a lack of activity.

github-actions[bot] avatar Jun 17 '23 00:06 github-actions[bot]

@dasch I dropped the ball here. Are you still interested in getting this in? If so, I'll rebase and add the functional test as asked in the next couple weeks.

RyanAmos avatar Jun 17 '23 01:06 RyanAmos

Sure!

dasch avatar Jun 21 '23 13:06 dasch