Skip to content

Commit

Permalink
Fix broker thread "hang" in CONNECT state (confluentinc#1397)
Browse files Browse the repository at this point in the history
With a zero rkb_blocking_max_ms the ua_idle() function would
not serve broker queues and IOs resulting in the broker thread practically
hanging and busy-looping.

This fix makes sure we serve it at least once per spin.
The previous fix makes sure rkb_blocking_max_ms is not 0.
  • Loading branch information
edenhill authored and Daniel Woodlins committed Nov 6, 2017
1 parent 76b5e0f commit 13c27d5
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions src/rdkafka_broker.c
Original file line number Diff line number Diff line change
Expand Up @@ -3332,14 +3332,16 @@ static void rd_kafka_broker_ua_idle (rd_kafka_broker_t *rkb, int timeout_ms) {
* in state ..BROKER_STATE_CONNECT we only run this loop
* as long as the state remains the same as the initial, on a state
* change - most likely to UP, a correct serve() function
* should be used instead. */
while (!rd_kafka_broker_terminating(rkb) &&
(int)rkb->rkb_state == initial_state &&
!rd_timeout_expired(rd_timeout_remains(abs_timeout))) {

* should be used instead.
* Regardless of constraints (terminating, timeouts), poll at
* least once. The state will not have changed on the first iteration.
*/
do {
rd_kafka_broker_toppars_serve(rkb);
rd_kafka_broker_serve(rkb, abs_timeout);
}
} while (!rd_kafka_broker_terminating(rkb) &&
(int)rkb->rkb_state == initial_state &&
!rd_timeout_expired(rd_timeout_remains(abs_timeout)));
}


Expand Down

0 comments on commit 13c27d5

Please sign in to comment.