-
Notifications
You must be signed in to change notification settings - Fork 902
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
"Commit failed: Local: No offset stored" + messages commited anyway #71
Comments
Can you provide your complete consumer conf dict? |
_NO_OFFSET is a "soft error", it means it didnt have to commit the offset because the current offset had already been committed. This might make sense in this case since the first on_commit indicates offset 27 was succesfully committed and the subsequent commit did not have any offsets to commit because no new messages were consumed. |
c = Consumer(**{
'client.id': 'test-client',
'bootstrap.servers': 'localhost',
'group.id': 'test-group',
'enable.auto.commit': False,
'enable.auto.offset.store': True,
'offset.store.method': 'broker',
'enable.partition.eof': True,
'default.topic.config': {'auto.offset.reset': 'smallest'},
'on_commit': on_commit,
'error_cb': error_cb,
}) |
Thanks. |
elif msg.error().code() == KafkaError._PARTITION_EOF:
print '_PARTITION_EOF'
# print c.position([p])
print 'commiting'
c.commit(async = False)
print 'commited'
break |
Okay, will try to reproduce. |
I can't reproduce this, can you provide a small script to reproduce the issue? |
from confluent_kafka import Consumer, KafkaError, TopicPartition
def on_commit (err, partitions):
print '**on_commit', err, partitions
def error_cb (err):
print '***error_cb', err.name(), err.str()
print 'consuming'
c = Consumer(**{
'client.id': 'test-client',
'bootstrap.servers': 'localhost',
'group.id': 'test-group',
'enable.auto.commit': False,
'enable.auto.offset.store': True,
'offset.store.method': 'broker',
'enable.partition.eof': True,
'default.topic.config': {'auto.offset.reset': 'smallest'},
'on_commit': on_commit,
'error_cb': error_cb,
})
print 'assigning'
p = TopicPartition('test', 0)
c.assign([p])
print 'getting position'
pos = c.position([p])
print pos, pos[0].offset
print 'polling'
try:
while True:
msg = c.poll(1)
if msg is None:
continue
if not msg.error():
print 'Received message: %s' % msg.value().decode('utf-8')
elif msg.error().code() != KafkaError._PARTITION_EOF:
print '***error', msg.error()
break
elif msg.error().code() == KafkaError._PARTITION_EOF:
print '_PARTITION_EOF'
print 'commiting'
c.commit(async = False)
print 'commited'
break
finally:
print 'closing'
c.close()
print 'closed' first run:
second run:
|
Awesome! This reproduces it reliably |
There's a stray commit() left in the C code for the case where no msg or partition list argument is given to commit(): That's why you get double commits. |
I recently started seeing this error in my consumer code on 2.5.0. Tried upgrading to 2.5.3 where this issue was supposedly fixed by this commit , however I still saw the error. I ended up having to downgrade to 2.0.2 to fix this. Here is the consumer code...
|
confluent-kafka==0.9.2, librdkafka 0.9.2, Python 2.7.6, kafka 0.10.1.0
It's me again..
I had a clean new topic 'test', in which I've produced some messages.
I have a consumer, which is configured with
'enable.auto.commit': False, 'enable.auto.offset.store': True, 'default.topic.config': {'auto.offset.reset': 'smallest'}
. I'm manually assigning a partiotion viaassign
. I consme messages until_PARTITION_EOF
, then.commit(async = False)
andfinally: .close()
.On the first run I see printed recieved messages and the following:
Moreover, I run the script again:
There were no messages, which means the offset was actually commited. Also why
on_commit
was called two times?The text was updated successfully, but these errors were encountered: