Closed jbfuzier closed 7 years ago
What is the intention with this:
'offset.store.method': None, # Get all messages back from beginning
?
Are you trying to disable the offset store? Or reverting it to default?
Also, you have duplicate keys in the librdkafka_config: default.topic.config
Sorry, this was a wrong copy paste from other tests.
The proper config (without the 2 errors you noticed) has the exact same behavior.
librdkafka_conf = {
'bootstrap.kafka': "10.252.18.190:9092",
'group.id': "kafka",
'session.timeout.ms': 6000,
'security.protocol': "sasl_plaintext",
'sasl.username': "kafka",
'sasl.password': "password",
'sasl.mechanisms': "PLAIN",
'statistics.interval.ms': 10000,
'enable.partition.eof': False,
'api.version.request': False,
'broker.version.fallback': '0.10.0.1',
'enable.auto.commit': True,
'auto.commit.interval.ms': 10000,
'topic.metadata.refresh.interval.ms': 20000,
'default.topic.config': {
'auto.offset.reset': 'earliest',
}
}
experiencing same issue. on_assing: allways gets offset== -1001L even if submit was called manually. Also, on_submit is not called when do: consumer.commit(msg, async=False) but get called on consumer.close() and restarting after calling consumer.close() cause same behaviour: on_assing: offset = -1001L
There is nothing in your logs that looks strange to me.
on_assign is called before committed offsets are fetched from the broker (to allow the application to use its own offsets instead), that's why all partitions have offset -1001 (which is the INVALID/unassigned/default offset constant). That is to say: the offsets are not relevant in on_assign, unless you update the offsets yourself and call assign() explicitly from on_assign.
position() reports the current fetch position, but the fetcher has not yet been started in on_assign since assign() hasn't been called yet: assign() will be called automatically when on_assign/on_revoke returns unless the application calls assign() from those callbacks.
sync commits with commit(async=False) will not trigger the on_commit callback, only automatic and async commits will do that (since that's the only way to find out the commit results).
@edenhill thanks for your response. I got it working.
thanks for the explanation
@edenhill I have a related question: will auto.commit handle the case when consumer.close() is called? In other words, do we need manual on_revoke handlers if we are using auto commit?
Thanks advanced!
@ParkerHao final offsets will be committed automatically on close() regardless of on_revoke.
on_assign is called before committed offsets are fetched from the broker (to allow the application to use its own offsets instead), that's why all partitions have offset -1001 (which is the INVALID/unassigned/default offset constant). That is to say: the offsets are not relevant in on_assign, unless you update the offsets yourself and call assign() explicitly from on_assign.
position() reports the current fetch position, but the fetcher has not yet been started in on_assign since assign() hasn't been called yet: assign() will be called automatically when on_assign/on_revoke returns unless the application calls assign() from those callbacks.
This would be AMAZING to have in the documentation for on_assign
. I've been banging my head against a wall wondering why a callback named on_assign
wasn't giving me all the details about the partitions the consumer was assigned to.
Is there a "lifecycle" diagram for a Consumer (and Producer for that matter) we could reference?
When in the lifecycle of a consumer is the earliest possible chance to know which offset of a partition the consumer will start at?
Hi,
I think I found an issue with the commit for consumers. On current master of confluent-kafka-python and librdkafka, Kafka v0.10. There are messages in the topic.
To reproduce the issue, run sample script, wait until auto commit get called (it does not raise any error). Stop by pressing CTRL+C (wait for closing). Launch the script again, offset are not set in assignment callback. Also if we set 'auto.offset.reset': 'error', it returns KafkaError{code=_NO_OFFSET,val=-168,str="no previously committed offset available"}.
Kafka ACLs :
Sample script :