GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
GeezerVison is showing github.com — [fix][broker] The offline consumer is not removed from the consumerList by lordcheng10 · Pull Request #14970 · apache/pulsar Conversation
|
|
#13787 |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Good catch. I wonder if it would be better to prevent adding duplicates to the list and doing a check in addConsumer? I think that would be a better solution to the problem.
I also have a suggestion to use removeIf there isn't a way to prevent duplicates getting added to the list.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| addUnAckedMessages(-consumer.getUnackedMessages()); | ||
| if (consumerSet.removeAll(consumer) == 1) { | ||
| consumerList.remove(consumer); | ||
| removeAllConsumer(consumer); |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
The removeAllConsumer doesn't look great. I wonder if using .removeIf would be better:
| removeAllConsumer(consumer); | |
| consumerList.removeIf(consumer::equals); |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
I agree with this sentiment. I wonder about the data structure itself, too. Why is it a list and not a set?
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
+1 to @lhotari 's suggestion
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
I agree to @lhotari 's suggestion
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Fixed:
1.do a check in addConsumer;
2.use removeIf;
PTAL,thanks! @lhotari @eolivelli
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
@lordcheng10 there's a minor checkstyle issue in the recent changes. please check that
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Fixed.
PTAL,thanks! @lhotari
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
|
In fact, the problem here may be the problem of consumer equality, similar to the previous producer problem. When there are duplicate consumers in the consumerList, it is possible to remove the actually successfully registered consumers when removing them. In our scenario, we also found a problem: when the consumer reconnects, the broker no longer pushes messages to these consumers. Through the stats command, we see these The consumer's permit is 0, and it is a consumer that has been removed from the consumerSet and consumers. The wrong consumer could be removed . So the fundamental problem here is actually the definition of consumer equality. I think we might need to do something like #12846 on the definition of equality for consumers. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
|
I think we also need to implement a method similar to isSuccessorTo to determine whether the consumer can be overridden, what do you think? @lhotari @michaeljmarshall @eolivelli like this: |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
@lordcheng10 - that is a great finding. I think it seems very reasonable to adjust the consumer logic, but I still haven't researched the consumer remove logic, so I am not authoritative on the subject. I wonder if we'd be able to add a test that shows the |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
2.use removeIf;
| log.warn("[{}] Consumer with the same id is already created:" | ||
| + " consumerId={}, consumer={}", | ||
| consumer.cnx().clientAddress(), consumer.consumerId(), consumer); | ||
| throw new BrokerServiceException("Consumer with the same id is already created!"); |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
what about using ConsumerBusyException ?
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Fixed.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| + " consumerId={}, consumer={}", | ||
| consumer.cnx().clientAddress(), consumer.consumerId(), consumer); | ||
| throw new BrokerServiceException("Consumer with the same id is already created!"); | ||
|
|
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
nit: remove useless newline
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Fixed. PTAL,thanks! @eolivelli
Sorry, something went wrong.
There was an error while loading. Please reload this page.
2.remove useless newline;
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
LGTM
although adding a test will help in understanding how to reproduce the problem
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
/pulsarbot run-failure-checks |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
/pulsarbot run-failure-checks |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| throw new ConsumerBusyException("Subscription reached max consumers limit"); | ||
| } | ||
|
|
||
| if (consumerList.contains(consumer)) { |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Can you provide the case of duplicated consumer?
I wonder if we should replace the old consumer with the new one. The older consumer maybe somewhat expired.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Yes so I think we should write a method like org.apache.pulsar.broker.service.Producer#isSuccessorTo to judge whether the previous consumer object should be overwritten by consumerEpoch,like this:
public boolean isSuccessorTo(Consumer other){
return Objects.equals(cnx.clientAddress(), other.cnx.clientAddress()) && consumerId == other.consumerId
&& other.consumerEpoch < consumerEpoch;
}
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Can you provide the case of duplicated consumer?
OK, I will try to find duplicate cases.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
/pulsarbot run-failure-checks |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
The pr had no activity for 30 days, mark with Stale label. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
The pr had no activity for 30 days, mark with Stale label. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Thanks @lordcheng10 for finding this. Your report about stale consumers in |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
Successfully merging this pull request may close these issues.
There was an error while loading. Please reload this page.