I have upgraded Eclipse Mosquitto on Debian from 1.5.7 to 2.0.11. After the upgrade I realized that
mosquitto_sub -v -t \$SYS/broker/# behaves differently. With 1.5.7 I got a first batch of results instantly, since 2.0.11 sometimes some subscriptions deliver quickly, sometimes one has to wait seconds or until a value changed (e.g. a client connected, a message got dropped etc.).
I’ve also shortly tested 2.0.14 and found it to behave just like my 2.0.11 broker in production.
I thought that the messages of $SYS/broker/# should be retained. Apparently that is not the case anymore. Did I get this wrong? Did I miss a config setting to change this? Or is there another way to reliably get these values if I want to access them only once in a while?
Version 2.0 added a change to expire $SYS messages after 60 seconds, with the intention that offline clients would not have a large queue of $SYS messages build up. This also meant that the retained messages were removed as well, if they had not changed. So where you have a constant number of subscriptions for 60 seconds, that $SYS retained message would be deleted. If you then subscribed to $SYS, the number of subscriptions would change and hence on the next update it would be republished - which describes exactly what you are seeing.
There is a fix for this in what will become 2.0.16, which I’m intending to release “soon” - there are a few other things I need to sort out first though.
You could also confirm this behaviour works as you expect with one of the trial instances from MQTT Broker - Pro Edition for Eclipse Mosquitto | Cedalo - which includes the same fix.