Skip to content

persistent_client_expiration only works within one run of mosquitto #2546

Closed
@ghost

Description

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Component: mosquitto-brokerStatus: CompletedNothing further to be done with this issue, it can be closed by the requestor or committer.

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions