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

kafkaConsumer fall into an infinite loop #2108

Closed
1 of 7 tasks
boatfish opened this issue Nov 15, 2018 · 3 comments
Closed
1 of 7 tasks

kafkaConsumer fall into an infinite loop #2108

boatfish opened this issue Nov 15, 2018 · 3 comments

Comments

@boatfish
Copy link

Read the FAQ first: https://github.com/edenhill/librdkafka/wiki/FAQ

Description

when use the high level api (class KafkaConsumer) to consume the message, we set a timeout for it, the consumer may fall into an infinite loop in function rd_kafka_q_pop_serve due to the timeout_tspec.tv_nsec is exactly equal 1000 million, which seems cased by the rd_timeout_init_timespec function in rdtime.h.

the code is
static RD_INLINE void rd_timeout_init_timespec (struct timespec *tspec,
int timeout_ms) {
if (timeout_ms == RD_POLL_INFINITE ||
timeout_ms == RD_POLL_NOWAIT) {
tspec->tv_sec = timeout_ms;
tspec->tv_nsec = 0;
} else {
timespec_get(tspec, TIME_UTC);
tspec->tv_sec += timeout_ms / 1000;
tspec->tv_nsec += (timeout_ms % 1000) * 1000000;
if (tspec->tv_nsec > 1000000000) {
tspec->tv_nsec -= 1000000000;
tspec->tv_sec++;
}
}
}
is that the "if (tspec->tv_nsec > 1000000000)" need to be amend to “if (tspec->tv_nsec >= 1000000000)” ?

How to reproduce

<your steps how to reproduce goes here, or remove section if not relevant>

IMPORTANT: Always try to reproduce the issue on the latest released version (see https://github.com/edenhill/librdkafka/releases), if it can't be reproduced on the latest version the issue has been fixed.

Checklist

IMPORTANT: We will close issues where the checklist has not been completed.

Please provide the following information:

  • librdkafka version (release number or git tag): <REPLACE with e.g., v0.10.5 or a git sha. NOT "latest" or "current">
  • Apache Kafka version: <REPLACE with e.g., 0.10.2.3>
  • librdkafka client configuration: <REPLACE with e.g., message.timeout.ms=123, auto.reset.offset=earliest, ..>
  • Operating system: <REPLACE with e.g., Centos 5 (x64)>
  • Provide logs (with debug=.. as necessary) from librdkafka
  • Provide broker log excerpts
  • Critical issue
@edenhill
Copy link
Contributor

Good catch!
Care to submit a PR?

@johnsenxu
Copy link

close function in KafkaConsumerImpl.cpp fall into an infinite loop too

edenhill added a commit that referenced this issue Nov 20, 2018
@edenhill
Copy link
Contributor

Thank you @boatfish , will land in master soon.

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

No branches or pull requests

3 participants