-
Notifications
You must be signed in to change notification settings - Fork 2.4k
fix(broker): avoid needless emqx_shared_sub
call on subscriber down
#15396
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(broker): avoid needless emqx_shared_sub
call on subscriber down
#15396
Conversation
Server `emqx_shared_sub` manages its own monitors and runs cleanups. Moreover, during high disconnect rate it can be overloaded with DOWN signals, and `unsubscribe/3` call can easily timeout.
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## release-510 #15396 +/- ##
===============================================
+ Coverage 81.74% 81.79% +0.04%
===============================================
Files 1116 1117 +1
Lines 81434 81549 +115
===============================================
+ Hits 66572 66704 +132
+ Misses 14862 14845 -17 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
do_unsubscribe_down(Topic, SubPid, SubOpts) -> | ||
true = ets:delete(?SUBOPTION, {Topic, SubPid}), | ||
case Topic of | ||
B when is_binary(B) -> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: maybe add a IS_SHARED_TOPIC macro in emqx_mqtt.hrl.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To keep most common case clauses first, I guess then we'd then need IS_REGULAR_TOPIC
, which is just is_binary(X)
?
@@ -210,24 +210,23 @@ unsubscribe(Topic) when ?IS_TOPIC(Topic) -> | |||
do_unsubscribe(Topic, SubPid, SubOpts) -> | |||
true = ets:delete(?SUBOPTION, {Topic, SubPid}), | |||
true = ets:delete_object(?SUBSCRIPTION, {SubPid, Topic}), | |||
do_unsubscribe2(Topic, SubPid, SubOpts). | |||
case Topic of | |||
B when is_binary(B) -> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: maybe add a IS_SHARED_TOPIC macro in emqx_mqtt.hrl.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll try to make it look nicer in the followup PRs.
Addresses #14011.
Release version: 5.10.1?
Summary
Server
emqx_shared_sub
manages its own monitors and runs cleanups. Moreover, during high disconnect rate it can be overloaded with DOWN signals, andunsubscribe/3
call can easily timeout.PR Checklist
changes/ee/(feat|perf|fix|breaking)-<PR-id>.en.md
files