Skip to content

Commit 803555e

Browse files
committed
Fix ConsumerGroup._checkTopicPartitionCheck
Previous behavior only check topics that this consumer is subscribed, if two consumer with same group id subscribed to different topic, group master cannot check topic partition change correctly, and rejoin the whole group each time such check is scheduled. This is because this.topicPartitionLength is initialized when joining group and contains all the topics that has been subscribed by this group, while this.topics may not contains all the topics. In such condition: ``` const topicOrPartitionsChanged = _.some(this.topicPartitionLength, function (numberOfPartitions, topic) { return numberOfPartitions !== _.get(metadata, `['${topic}'].length`, 0); }); ``` So `topicPartitionChanged` will always be caculated to be true.
1 parent 51b6292 commit 803555e

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

lib/consumerGroup.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -318,7 +318,8 @@ ConsumerGroup.prototype.scheduleTopicPartitionCheck = function () {
318318
};
319319

320320
ConsumerGroup.prototype._checkTopicPartitionChange = function (callback) {
321-
this.client.loadMetadataForTopics(this.topics, (error, metadataResponse) => {
321+
const topics = Object.keys(this.topicPartitionLength);
322+
this.client.loadMetadataForTopics(topics, (error, metadataResponse) => {
322323
if (error) {
323324
return callback(error);
324325
}

0 commit comments

Comments
 (0)