[fix] [broker]Consumption stuck due to orphan consumers after the connection reconnect - #20573
[fix] [broker]Consumption stuck due to orphan consumers after the connection reconnect#20573poorbarcode wants to merge 2 commits into
Conversation
…erverCnx.java Co-authored-by: Penghui Li <penghui@apache.org>
merlimat
left a comment
There was a problem hiding this comment.
👍 Nice catch and the fix looks good.
I wonder if we should force-close the connection and clear the consumer as well, when there is the socket write failure because the connection was already closed.
|
Close this PR because the logic which this PR does already exists: https://github.com/apache/pulsar/blob/master/pulsar-broker/src/main/java/org/apache/pulsar/broker/service/persistent/PersistentTopic.java#L894-L915 |
I did it in the PR #20568: do a health check immediately(if the health check fail, the connection will be closed) if got an IO error when sending messages to the client. |
Motivation
There may leave an orphan consumer after the
ServerCnxclosed, which would cause consumption to get stuck. For example:add a new consumerconnection health checkServerCnx.closeinto theeventLoopcmd subscribeinto theeventLoop[1]: see [improve] [broker] Improve dispatcher log to trace io error that may cause consumption stuck #20568
Modifications
Just like producer registration[2]: add a checker
connection.isAtiveafter the consumer created complete.[2]: https://github.com/apache/pulsar/blob/master/pulsar-broker/src/main/java/org/apache/pulsar/broker/service/ServerCnx.java#LL1601C45-L1601C45
Documentation
docdoc-requireddoc-not-neededdoc-completeMatching PR in forked repository
PR in forked repository: x