Open bwojdyla opened 1 year ago
I am able to reproduce it. Issue: Start subscribers S1, S2 and S3:::::: S1 -> S2 -> S3
Topics are formed
Stop subscribers
Publish Messages on these topics S1, S2 and S3
Start back subscribers. These pending messages will be subscribed multiple times.
It happens during this time. Subscription happens and paho.mqtt receives a message for it. Then, subscription disconnects and again connects. This is the moment when message is re-sent.
Subscribe for S1 is called.
Subscribe for S2 is called.
Subscribe for S3 is called.
In all, 3 times pending message received for S1, 2 times for S2 and 1 time for S3.
Now, there are 2 questions:
Q.1. Why Dapr runtime subscribes to topics 1 by 1. Why it can't subscribe for all topics in one go? I have created https://github.com/dapr/dapr/issues/5571 to discuss and conclude on that.
Q.2. Even if Dapr runtime subscribes to messages 1 by 1, is there a way out for now on component side?
Even if Dapr runtime is changed, it will be a big task and will need consensus to be arrived and then actual work will require time [being very optimistic], but what can be the way out right now?
Can MQTT delay receiving of messages after subscription start, so that all topics are subscribed and only then messages are received. It will ensure that messages are not repeated in the pattern due to which this issue is filed. But, how to determine this delay. This sounds like a error-prone hack.
Rather, can MQTT or similar kinda component start subscription only when it has known all topics to be subscribed. And, before that, it was just adding topic list. But, how do we know that inside component. This is doable, if Dapr runtime can send info to component that what topic is last topic to be subscribed to.
This can be achieved, if we send some flag like lastSubscriptionTopic
along with topic metadata set to true.
This issue has been automatically marked as stale because it has not had activity in the last 30 days. It will be closed in the next 7 days unless it is tagged (pinned, good first issue, help wanted or triaged/resolved) or other activity occurs. Thank you for your contributions.
This issue has been automatically closed because it has not had activity in the last 37 days. If this issue is still valid, please ping a maintainer and ask them to label it as pinned, good first issue, help wanted or triaged/resolved. Thank you for your contributions.
Expected Behavior
Pending messages should be delivered once when consumer starts for qos=2. Same issue happens when qos=1. One might argue that qos=1 states 'At least once'. But we might expect redelivery in case of some failure. But in scenario below it looks like regular behavior on startup.
Actual Behavior
If there are some pending messages when consumer starts then they might be delivered more than once.
Steps to Reproduce the Problem
Configure 2 subscribtions for mqtt component:
Subscription 1
Subscription 2
Notice that:
Mosquitto logs:
For each topic (but not first) disconnect occurs. Maybe this is the source of problem?