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

persistent_client_expiration only works within one run of mosquitto #2546

Closed
JSchy65 opened this issue May 23, 2022 · 4 comments
Closed

persistent_client_expiration only works within one run of mosquitto #2546

JSchy65 opened this issue May 23, 2022 · 4 comments
Labels
Component: mosquitto-broker Status: Completed Nothing further to be done with this issue, it can be closed by the requestor or committer. Type: Bug

Comments

@JSchy65
Copy link

JSchy65 commented May 23, 2022

mosquitto broker version 2.0.14 (Ubuntu 20.04) and 1.6.15. (CentOS 8)

The promise, that clients are removed if the persistent_client_expiration time is exceeded, is only kept for clients that are disconnected during the current run of the mosquitto broker.

The consequence of this is, that if the mosquitto brokers uptime is less than the persistent_client_expiration time, clients that are disconnected during that run are NEVER removed.

Imagine that someone has configured a persistent_client_expiration e.g. for one week. If, for some reasons, the mosquitto is restarted before the week is over, the clients disconnected during the first days of that week will NEVER be removed and their related messages will be stored FOREVER.

In my opinion, this makes the usage of that option useless (if long periods of time are configured for that parameter). Or it gives the user a false sense of security that his broker will never be flooded with messages no one is waiting for anymore.

In my opinion, the solution is to consider ALL disconnected clients for removement if the persistent_client_expiration is exceeded.

Here is a short excerpt from the log file to show the situation.
See the attached log file for more details.

mosquitto-v2.0.14.log.zip

Configuration:

persistent_client_expiration 1h
persistence true
persistence_location /var/lib/mosquitto/

Log excerpt:


1st run:

15:19:43
broker/version mosquitto version 2.0.14
broker/uptime 88 seconds
clients/total 1
messages/count 53

15:21:18
create 25 clients with clienIds 100..124

15:23:21
disconnect 25 clients 100..124

15:23:39
send 500 messages

15:24:01
uptime 253 seconds
clients/total 26
messages/count 553


2nd run:

15:26:47
restart mosquitto

15:27:19
create 50 clients with ClientIds 200..249

15:27:45
disconnect 50 clients 200..249

15:28:47
send 300 messages

15:28:59
broker/uptime 132 seconds
clients/total 76 (+ 50 clients since 1st run)
messages/count 853 (+300 messages since 1st run)

16:27:46
removed clients 200..249 "Expiring client due to timeout" <- as expected 1h after disconnect

16:39:09
uptime 4334 seconds
clients/total 26 !!! (clients from the 1st run still exist)
messages/count 852 !!! (messages for the clients from 1st run still exist)

->
Only the clients 200..249 disconnected during the 2nd run were removed.
The clients 100..125 disconnected during the 1st run are NOT removed.
Because that these clients are not removed, all 800 messages sent before still exist.

Thank You very much, Regards
Joachim Schachermayer

ralight added a commit that referenced this issue May 23, 2022
…g from persistence.

Closes #2546. Thanks to Joachim Schachermayer.
ralight added a commit that referenced this issue May 23, 2022
…g from persistence.

Closes #2546. Thanks to Joachim Schachermayer.
@ralight
Copy link
Contributor

ralight commented May 23, 2022

Thank you, you're quite right. Helpfully there was a nice FIXME in the code describing this same problem and I've now pushed changes that address this issue.

@ralight ralight added Type: Bug Component: mosquitto-broker Status: Completed Nothing further to be done with this issue, it can be closed by the requestor or committer. labels May 23, 2022
@JSchy65
Copy link
Author

JSchy65 commented May 24, 2022

Thank you very much. The solution cames pretty much faster than expected, very helpful :-)

@JSchy65
Copy link
Author

JSchy65 commented May 24, 2022

I have tested the fix and it behaved as expected.

@JSchy65 JSchy65 closed this as completed May 24, 2022
@ralight
Copy link
Contributor

ralight commented May 25, 2022

Thanks for confirming.

ralight added a commit that referenced this issue Aug 9, 2022
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 28, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Component: mosquitto-broker Status: Completed Nothing further to be done with this issue, it can be closed by the requestor or committer. Type: Bug
Projects
None yet
Development

No branches or pull requests

2 participants