Skip to content
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

persistence: autosave_on_changes does not trigger when number of queued messages decreases #1726

Closed
nduhme opened this issue Jun 17, 2020 · 1 comment
Labels
Status: Completed Nothing further to be done with this issue, it can be closed by the requestor or committer.
Milestone

Comments

@nduhme
Copy link

nduhme commented Jun 17, 2020

Hi,
i found a special case that seems to violate QoS2 in case of the broker crashing.

I am using mosquitto 1.6.9 to collect data that should be delivered exactly once (QoS2). In my system there are multiple publishers (50-100) and a single persistent subscriber for that i want to be sure that he gets all queued messages (no Clean Start).

To prevent potential loss of messages when the broker might crash i set
autosave_on_changes true
autosave_interval 1
persistence true
in the configuration file.

I found that when i have a subscriber with QoS2 that is temporarily not available every queued message is saved to the mosquitto.db file. So far so good.
If i now reconnect the subscriber all messages are sent to it, but the mosquitto.db file still contains all the queued messages. This seems to be the case because successfully sending a message (decreasing the queue) does not trigger the autosave_on_change. If the broker crashes and is restarted now the information that these messages were already recevied by the subscriber is lost. After restarting the broker and reconnecting the subscriber the messages will be sent a second time which violates QoS2 as the subscriber received them twice.

Steps to reproduce:
0 - Set configuration file: autosave_on_changes true, autosave_interval 1, persistence true
1 - Subscribe to topic T with QoS2
2 - Disconnect subscriber
3 - Publish messages with QoS2 to topic T (these are queued and trigger the autosave_on_change)
4 - Reconnect subcriber (no Clean Start)
5 - wait till all queued messages are revecied by subscriber
6 - Stop mosquitto broker by killing the task (simulating a crash)
7 - Restart mosquitto broker
8 - Reconnect subcriber (no Clean Start)
=> now the messages that were already received in step 5 will be received again

It would be great if there was an option to also autosave when the queue decreases otherwise i would have to downgrade my subscriber to QoS1.

@ralight
Copy link
Contributor

ralight commented Jul 15, 2020

Thanks for the nice details and sorry to not get to this sooner. I've pushed a change to the fixes branch that should sort this.

@ralight ralight added the Status: Completed Nothing further to be done with this issue, it can be closed by the requestor or committer. label Jul 15, 2020
@ralight ralight added this to the 1.6.11 milestone Jul 16, 2020
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 11, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Status: Completed Nothing further to be done with this issue, it can be closed by the requestor or committer.
Projects
None yet
Development

No branches or pull requests

2 participants