Skip to content

Conversation

@laz2
Copy link
Contributor

@laz2 laz2 commented Dec 19, 2016

KafkaConsumer can not resubscribe to new pattern without this fix because setting empty topics list always does not request metadata.

Does KafkaClient.set_topics need additional kwarg for request metadata?

PS. KafkaConsumer.unsubcribe calls set_topics with empty list. Is this problem?

@dpkp
Copy link
Owner

dpkp commented Dec 19, 2016

Perhaps a simpler change would be to add a call to self._client.cluster.request_update() to KafkaConsumer.subscribe() whenever it is called with a pattern. This is basically how the java client handles this case.

@laz2
Copy link
Contributor Author

laz2 commented Dec 19, 2016

So may be remove call request_update() and future return value from KafkaClient.set_topics?

@dpkp
Copy link
Owner

dpkp commented Dec 19, 2016

I dont think we need to change the set_topics code at all if the main issue is that pattern subscriptions are not requesting a metadata update on subscribe(). If that is the problem, why not request a metadata update directly from subscribe() ?

@laz2
Copy link
Contributor Author

laz2 commented Dec 19, 2016

Is error Broken pipe problem?

@dpkp
Copy link
Owner

dpkp commented Dec 19, 2016

no, unrelated error during test cleanup / client shutdown

@laz2
Copy link
Contributor Author

laz2 commented Dec 23, 2016

Any suggestions about this problem?

@dpkp dpkp merged commit 4acb7f4 into dpkp:master Dec 27, 2016
@laz2 laz2 deleted the fix-set-empty-topics branch December 28, 2016 17:37
@jeffwidman
Copy link
Contributor

What was the underlying problem here?

I'm a little unclear what this fixes and trying to track down a bug that might be related. Did this apply to a consumer that subscribes to a valid regex pattern and receives no topics in reply because none exist yet?

@dpkp
Copy link
Owner

dpkp commented Jan 5, 2017

jeff: the issue would apply to consumers that have already fetched metadata (perhaps by initially subscribing to a topic list). So:

consumer.subscribe(topics=['foo'])
consumer.poll()
consumer.subscribe(pattern='foo*')
consumer.poll()

Pattern subscriptions in general will only get "updates" every metadata_max_age_ms when the client refreshes metadata to get new topic information -- or if there is a broker restart etc that triggers an immediate refresh.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants