question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Help: Non deterministic behavior between producers and consumers

See original GitHub issue

Example code:

def test_one(timeout, sleep):
    consumer = KafkaConsumer('test.test_one', group_id=None,
                             bootstrap_servers='localhost:9093')
    producer = KafkaProducer(bootstrap_servers='localhost:9093')

    producer.send('test.test_one', b'test_one')
    time.sleep(sleep)
    p = consumer.poll(timeout)
    print p
    return p == {}

Sometimes the consumer sees the message sent by the producer, sometimes it doesn’t. A non python consumer sees every message sent by the producer, so it is not kafka itself that is the issue, rather it is something in the consumer. sleep was added on the thinking that it could be timing related to poll too soon after the message was sent, but does not seem to have made any impact for a variety of sleep durations, same with adjusting the poll timeout duration.

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:11 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
dpkpcommented, Apr 29, 2016

producer.send is asynchronous by default; you should do something like this if you want a delivery guarantee producer.send('test.test_one', b'test_one').get(timeout) or just call producer.flush().

Have you also verified that your consumer.poll() is not hitting the timeout? If it is unable to fetch records before the timeout, it will return {}

0reactions
jaytailorcommented, Aug 11, 2017

i was also using latest and it caused issues for me as fetcher was in loop forever. When i used earliest it helped me.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to Avoid the Headache With Non-deterministic Bugs in ...
Typically, non-deterministic behavior is caused by three things: lack ... Your customers can be the first to spot a problem in a production...
Read more >
Trying to achieve deterministic behavior on recovery/rewind ...
Hey Roger, To add onto Chris's discussion we put some thought from early on into how to get exact semantics in Samza.
Read more >
Exactly-Once Semantics Are Possible: Here's How Kafka Does It
At-least-once semantics: if the producer receives an acknowledgement (ack) from the Kafka broker and acks=all, it means that the message has been written ......
Read more >
Kafka : Producers-Consumers & Partitions - Dev Genius
Understanding partitions,Consumers helps you learn Kafka faster. here we discuss about behaviour of Kafka's ... USE CASE 3:No of partitions=no of consumers.
Read more >
HELP! Ebean shows non deterministic behavior
In our code we do this over 10000 entries and sometimes we the City is null, sometimes the name of the Customer. If...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found