-
Notifications
You must be signed in to change notification settings - Fork 3.2k
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
Move can_q_contain_fetched_msgs inside q_serve #4431
Changes from all commits
f4a50cd
92aeab4
ab8c71e
69e0942
e69087d
bc0933b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -360,19 +360,25 @@ static void do_test_with_log_queue(void) { | |
* should suffice. | ||
* We test with the result of rd_kafka_queue_get_consumer, and an arbitrary | ||
* queue that is forwarded to by the result of rd_kafka_queue_get_consumer. | ||
* We also test with an arbitrary queue that is forwarded to the the result of | ||
* rd_kafka_queue_get_consumer. | ||
*/ | ||
static void | ||
do_test_rejoin_after_interval_expire(rd_bool_t forward_to_another_q) { | ||
do_test_rejoin_after_interval_expire(rd_bool_t forward_to_another_q, | ||
rd_bool_t forward_to_consumer_q) { | ||
const char *topic = test_mk_topic_name("0089_max_poll_interval", 1); | ||
rd_kafka_conf_t *conf; | ||
char groupid[64]; | ||
rd_kafka_t *rk = NULL; | ||
rd_kafka_queue_t *consumer_queue = NULL; | ||
rd_kafka_event_t *event = NULL; | ||
rd_kafka_queue_t *polling_queue = NULL; | ||
rd_kafka_t *rk = NULL; | ||
rd_kafka_queue_t *consumer_queue = NULL; | ||
rd_kafka_queue_t *forwarder_queue = NULL; | ||
rd_kafka_event_t *event = NULL; | ||
rd_kafka_queue_t *polling_queue = NULL; | ||
|
||
SUB_TEST("Testing with forward_to_another_q = %d", | ||
forward_to_another_q); | ||
SUB_TEST( | ||
"Testing with forward_to_another_q = %d, forward_to_consumer_q = " | ||
"%d", | ||
forward_to_another_q, forward_to_consumer_q); | ||
|
||
test_create_topic(NULL, topic, 1, 1); | ||
|
||
|
@@ -393,6 +399,10 @@ do_test_rejoin_after_interval_expire(rd_bool_t forward_to_another_q) { | |
if (forward_to_another_q) { | ||
polling_queue = rd_kafka_queue_new(rk); | ||
rd_kafka_queue_forward(consumer_queue, polling_queue); | ||
} else if (forward_to_consumer_q) { | ||
forwarder_queue = rd_kafka_queue_new(rk); | ||
rd_kafka_queue_forward(forwarder_queue, consumer_queue); | ||
polling_queue = forwarder_queue; | ||
} else | ||
polling_queue = consumer_queue; | ||
|
||
|
@@ -430,17 +440,67 @@ do_test_rejoin_after_interval_expire(rd_bool_t forward_to_another_q) { | |
|
||
if (forward_to_another_q) | ||
rd_kafka_queue_destroy(polling_queue); | ||
if (forward_to_consumer_q) | ||
rd_kafka_queue_destroy(forwarder_queue); | ||
rd_kafka_queue_destroy(consumer_queue); | ||
test_consumer_close(rk); | ||
rd_kafka_destroy(rk); | ||
|
||
SUB_TEST_PASS(); | ||
} | ||
|
||
static void consume_cb(rd_kafka_message_t *rkmessage, void *opaque) { | ||
TEST_SAY("Consume callback\n"); | ||
} | ||
|
||
/** | ||
* @brief Test that max.poll.interval.ms is reset when | ||
* rd_kafka_poll is called with consume_cb. | ||
* See issue #4421. | ||
*/ | ||
static void do_test_max_poll_reset_with_consumer_cb(void) { | ||
const char *topic = test_mk_topic_name("0089_max_poll_interval", 1); | ||
rd_kafka_conf_t *conf; | ||
char groupid[64]; | ||
rd_kafka_t *rk = NULL; | ||
|
||
SUB_TEST(); | ||
|
||
test_create_topic(NULL, topic, 1, 1); | ||
uint64_t testid = test_id_generate(); | ||
|
||
test_produce_msgs_easy(topic, testid, -1, 100); | ||
|
||
test_str_id_generate(groupid, sizeof(groupid)); | ||
test_conf_init(&conf, NULL, 60); | ||
test_conf_set(conf, "session.timeout.ms", "10000"); | ||
test_conf_set(conf, "max.poll.interval.ms", "10000" /*10s*/); | ||
test_conf_set(conf, "partition.assignment.strategy", "range"); | ||
rd_kafka_conf_set_consume_cb(conf, consume_cb); | ||
|
||
rk = test_create_consumer(groupid, NULL, conf, NULL); | ||
rd_kafka_poll_set_consumer(rk); | ||
|
||
test_consumer_subscribe(rk, topic); | ||
TEST_SAY("Subscribed to %s and sleeping for 5 s\n", topic); | ||
rd_sleep(5); | ||
rd_kafka_poll(rk, 10); | ||
TEST_SAY( | ||
"Polled and sleeping again for 6s. Max poll should be reset\n"); | ||
rd_sleep(6); | ||
|
||
/* Poll should work */ | ||
rd_kafka_poll(rk, 10); | ||
test_consumer_close(rk); | ||
rd_kafka_destroy(rk); | ||
} | ||
|
||
int main_0089_max_poll_interval(int argc, char **argv) { | ||
do_test(); | ||
do_test_with_log_queue(); | ||
do_test_rejoin_after_interval_expire(rd_false); | ||
do_test_rejoin_after_interval_expire(rd_true); | ||
do_test_rejoin_after_interval_expire(rd_false, rd_false); | ||
do_test_rejoin_after_interval_expire(rd_true, rd_false); | ||
do_test_rejoin_after_interval_expire(rd_false, rd_true); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think we should add a test for the specific case that brought this bug to light, too, which uses There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Added a new test, though |
||
do_test_max_poll_reset_with_consumer_cb(); | ||
return 0; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Documentation comment above this test
We can also mention issue # for the original case
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, added.