Skip to content

Commit

Permalink
Fix ConsumerGroup._checkTopicPartitionCheck
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
thynson committed Nov 8, 2019
1 parent fcc8aef commit 55b4451
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion lib/consumerGroup.js
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,8 @@ ConsumerGroup.prototype.scheduleTopicPartitionCheck = function () {
};

ConsumerGroup.prototype._checkTopicPartitionChange = function (callback) {
this.client.loadMetadataForTopics(this.topics, (error, metadataResponse) => {
const topics = Object.keys(this.topicPartitionLength);
this.client.loadMetadataForTopics(topics, (error, metadataResponse) => {
if (error) {
return callback(error);
}
Expand Down

0 comments on commit 55b4451

Please sign in to comment.