Skip to content

Shared subscriptions #675

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

Closed
wants to merge 4 commits into from
Closed

Shared subscriptions #675

wants to merge 4 commits into from

Conversation

redboltz
Copy link
Owner

No description provided.

jonesmz and others added 2 commits October 7, 2020 01:21
Cleaned up code.
Fixed index position bug.
Fixed shared_subs_ adding algorithm.
@redboltz
Copy link
Owner Author

Shared subscription publish deliver test is passed.
Unsubscribing shared subscription test is not passed yet because it is not implemented yet.

@codecov
Copy link

codecov bot commented Oct 12, 2020

Codecov Report

Merging #675 into master will decrease coverage by 2.43%.
The diff coverage is n/a.

@@            Coverage Diff             @@
##           master     #675      +/-   ##
==========================================
- Coverage   82.69%   80.25%   -2.44%     
==========================================
  Files          46       45       -1     
  Lines        7077     6945     -132     
==========================================
- Hits         5852     5574     -278     
- Misses       1225     1371     +146     

@redboltz
Copy link
Owner Author

shared subscriptions notation

$share/share_name/topic_filter

Question

Is share_name is upper concept than topic_filter ?
What is expected behavior on the round robin algorithm in the following case ?

client id share_name topic_filter
s1 share1 topic1
s2 share1 topic1
s2 share1 topic2

The important point is s2 subscribes the topic_filter topic1 and topic2 using the same share_name share1.

The publisher publishes topic1, topic2, topic1, topic2 ..., then should the receive order be s1, s2, s1, s2 .... ?

Applied coding rules.
Rename tags.

For example, tag_combined used for multiple **combined** tags.
I prefer to tag means a set of keys directly.
@redboltz redboltz force-pushed the shared_subscriptions branch from 34de121 to 1f5d8db Compare October 12, 2020 07:21
@redboltz
Copy link
Owner Author

I got https://github.com/redboltz/mqtt_cpp/pull/675/checks?check_run_id=1240841796#step:7:119 errors.

It seems that s1 receives topic2 even if s1 only (shared) subscribes topic1.
https://github.com/redboltz/mqtt_cpp/pull/675/files#diff-9de1a1b00248c36cba4fd77cd442ae30R203

And s2 receives topic1 unexpected timing.
https://github.com/redboltz/mqtt_cpp/pull/675/files#diff-9de1a1b00248c36cba4fd77cd442ae30R240

At least former (s1 receives topic2) is wrong. I will debug it.

@redboltz
Copy link
Owner Author

redboltz commented Oct 12, 2020

I added logs.

Now, test program take a severity level parameter. (default is warning)

> ./shared_sub -- trace

invalid round robin and invalid topic match are detected.

NOTE: The message start with === is I added manually test edit.

*** 2 failures are detected in the test module "mqtt_client_cpp_test"
[kondo@archboltz] $ ./shared_sub -- trace                                                                                             [shared_subscriptions][~/work/mqtt_cpp/build/test]
Running 1 test case...
18:31:42.841658 T:1 S:info    C:mqtt_api endpoint.hpp:193 A:0x7f8980001550 create version:undetermined async_send_store:false
18:31:42.841723 T:1 S:info    C:mqtt_api endpoint.hpp:863 A:0x7f8980001550 start_session
18:31:42.841858 T:1 S:info    C:mqtt_api endpoint.hpp:1776 A:0x7f8980001550 connack session_present:false reason:success
18:31:42.842190 T:1 S:info    C:mqtt_api endpoint.hpp:193 A:0x7f8980005710 create version:undetermined async_send_store:false
18:31:42.842244 T:1 S:info    C:mqtt_api endpoint.hpp:863 A:0x7f8980005710 start_session
18:31:42.842337 T:1 S:info    C:mqtt_api endpoint.hpp:1776 A:0x7f8980005710 connack session_present:false reason:success
18:31:42.842631 T:1 S:info    C:mqtt_api endpoint.hpp:193 A:0x7f89800068d0 create version:undetermined async_send_store:false
18:31:42.842685 T:1 S:info    C:mqtt_api endpoint.hpp:863 A:0x7f89800068d0 start_session
18:31:42.842780 T:1 S:info    C:mqtt_api endpoint.hpp:1776 A:0x7f89800068d0 connack session_present:false reason:success


=== s1 subscribe share1 topic1
18:31:42.843075 T:1 S:trace   C:mqtt_broker test_broker.hpp:1090 A:0x7f8980005710 subs_.emplace() topic:topic1 qos:at_most_oncerap:dont
18:31:42.843131 T:1 S:info    C:mqtt_api endpoint.hpp:1945 A:0x7f8980005710 suback pid:1
18:31:42.843198 T:1 S:trace   C:mqtt_broker test_broker.hpp:1161 A:0x7f8980005710 shared_subs_.emplace() share:share1 topic:topic1


=== s2 subscribe share1 topic1
18:31:42.843373 T:1 S:trace   C:mqtt_broker test_broker.hpp:1090 A:0x7f89800068d0 subs_.emplace() topic:topic1 qos:at_most_oncerap:dont
18:31:42.843427 T:1 S:info    C:mqtt_api endpoint.hpp:1945 A:0x7f89800068d0 suback pid:1
18:31:42.843492 T:1 S:trace   C:mqtt_broker test_broker.hpp:1161 A:0x7f89800068d0 shared_subs_.emplace() share:share1 topic:topic1


=== s2 subscribe share1 topic2
18:31:42.843680 T:1 S:trace   C:mqtt_broker test_broker.hpp:1090 A:0x7f89800068d0 subs_.emplace() topic:topic2 qos:at_most_oncerap:dont
18:31:42.843736 T:1 S:info    C:mqtt_api endpoint.hpp:1945 A:0x7f89800068d0 suback pid:2
18:31:42.843800 T:1 S:trace   C:mqtt_broker test_broker.hpp:1161 A:0x7f89800068d0 shared_subs_.emplace() share:share1 topic:topic2

=== p1 publish topic1 1st
=== p1 publish topic2 2nd
=== p1 publish topic1 3rd
=== p1 publish topic2 4th


=== 1st pub deliver to s1 (0x7f8980005710)

18:31:42.844028 T:1 S:trace   C:mqtt_broker test_broker.hpp:1297 A:0x7f8980005710 deliver pub  topic:topic1
18:31:42.844080 T:1 S:info    C:mqtt_api endpoint.hpp:1262 A:0x7f8980005710 publish pid:0 topic:topic1 qos:at_most_once retain:no dup:no


=== 2nd pub deliver to s2 (0x7f89800068d0)

18:31:42.844192 T:1 S:trace   C:mqtt_broker test_broker.hpp:1297 A:0x7f89800068d0 deliver pub  topic:topic2
18:31:42.844234 T:1 S:info    C:mqtt_api endpoint.hpp:1262 A:0x7f89800068d0 publish pid:0 topic:topic2 qos:at_most_once retain:no dup:no


=== 3rd pub deliver to s2 (0x7f89800068d0) **invalid round robin**

18:31:42.844332 T:1 S:trace   C:mqtt_broker test_broker.hpp:1297 A:0x7f89800068d0 deliver pub  topic:topic1
18:31:42.844371 T:1 S:info    C:mqtt_api endpoint.hpp:1262 A:0x7f89800068d0 publish pid:0 topic:topic1 qos:at_most_once retain:no dup:no


=== 4th pub deliver to s1 (0x7f8980005710) **invalid topic match**

18:31:42.844468 T:1 S:trace   C:mqtt_broker test_broker.hpp:1297 A:0x7f8980005710 deliver pub  topic:topic2
/home/kondo/work/mqtt_cpp/test/shared_sub.cpp(240): error: in "test_shared_sub/qos0": check topic == "topic2" has failed [topic1 != topic2]
18:31:42.844507 T:1 S:info    C:mqtt_api endpoint.hpp:1262 A:0x7f8980005710 publish pid:0 topic:topic2 qos:at_most_once retain:no dup:no
/home/kondo/work/mqtt_cpp/test/shared_sub.cpp(203): error: in "test_shared_sub/qos0": check topic == "topic1" has failed [topic2 != topic1]


18:31:42.844808 T:1 S:trace   C:mqtt_broker test_broker.hpp:1186 A:0x7f8980005710 unsub share:share1 topic:topic1
18:31:42.844860 T:1 S:trace   C:mqtt_broker test_broker.hpp:1191 A:0x7f8980005710 subs_.erase()
18:31:42.844902 T:1 S:info    C:mqtt_api endpoint.hpp:2011 A:0x7f8980005710 unsuback pid:2

@redboltz
Copy link
Owner Author

I thin that saved_shared_subs_ is not needed. See #672 (comment)
I will re-design shared subscription mechanism later and at that time, I refer to #672 and #675

@redboltz
Copy link
Owner Author

I close the PR. It doesn't mean stop developing shared subscription support.
Now, I'm working for integrate the new subscription model based on trie to the test_broker.
It is pretty big update.

After I updated it, then re-start developing shared subscription support.

@redboltz redboltz closed this Oct 27, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants