Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle EOF partition error properly in Consumer#each #12

Closed
jurriaan opened this issue Nov 18, 2017 · 7 comments
Closed

Handle EOF partition error properly in Consumer#each #12

jurriaan opened this issue Nov 18, 2017 · 7 comments
Assignees
Labels

Comments

@jurriaan
Copy link

When trying this library I got the following error:

/app/vendor/bundle/ruby/2.4.0/gems/rdkafka-0.3.3/lib/rdkafka/consumer.rb:186:in `poll': Broker: No more messages (partition_eof) (Rdkafka::RdkafkaError)
	from /app/vendor/bundle/ruby/2.4.0/gems/rdkafka-0.3.3/lib/rdkafka/consumer.rb:207:in `block in each'
	from /app/vendor/bundle/ruby/2.4.0/gems/rdkafka-0.3.3/lib/rdkafka/consumer.rb:206:in `loop'
	from /app/vendor/bundle/ruby/2.4.0/gems/rdkafka-0.3.3/lib/rdkafka/consumer.rb:206:in `each'

I think the #each method should handle these errors (ignore them, or pass these notifications to the block). Currently the each method itself raises an exception when you reach the end of the partition which is probably not what people expect from this library.

@thijsc thijsc self-assigned this Nov 20, 2017
@thijsc
Copy link
Collaborator

thijsc commented Nov 20, 2017

You can configure this behaviour with enable.partition.eof. I agree that it's counterintuitive that this happens with each by default.

I see a few options:

  • each could handle the exception and just keep going
  • each could handle the exception and yield some kind of special eof message
  • We could set enable.partition.eof to true by default

I think probably handling the exception makes the most sense. Not sure what is the nicest way to handle this, will think about it. What do you think?

@thijsc thijsc added this to the Feature complete milestone Feb 7, 2018
@thijsc thijsc added the bug label Feb 7, 2018
@jurriaan
Copy link
Author

jurriaan commented Mar 2, 2018

I'm currently writing a Kafka Streams-like processor where I want to store the state in a compacted topic and read the state back into memory on start for which I need to know when I'm done. This could be accomplished by this special eof message. For most processors however this EOF messages is not needed so this should be configurable IMO.

@thijsc
Copy link
Collaborator

thijsc commented Mar 2, 2018

It is configurable already with enable.partition.eof, which is true by default in librdkafka.

@jurriaan
Copy link
Author

jurriaan commented Mar 2, 2018

@thijsc Ah yes, of course, there is no need for a configuration option in this library then, when the library receives an eof 'error' message it should yield some kind of special eof message. The enable.partition.eof flag can then be used to adjust this behaviour.

@thijsc
Copy link
Collaborator

thijsc commented Mar 2, 2018

Indeed. This issue is still open because I want to make the error handling nicer, but the configuration is good as is.

@thijsc
Copy link
Collaborator

thijsc commented Aug 22, 2018

By the way: If you want complete control over this you're probably better off calling poll in a loop.

@thijsc
Copy link
Collaborator

thijsc commented Aug 15, 2019

I'm still not sure how to make this better than it is, so decided to add a note in 45055f1 and close this. If anyone has good ideas about this one feel free to reopen.

@thijsc thijsc closed this as completed Aug 15, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

No branches or pull requests

2 participants