MQTT device discovery only partially working

Hi, I’m using zigbee2mqtt 1.37 to ship data into HASS. I’ve recently started having problems with autodiscovery of entities in hass. In MQTTExplorer, I see the full set of entities I expect in the discovery topic, yet only see some of them get picked up in hass - The rest (that had previously been discovered and added to hass), show as unavailable in hass.

I dont see anything suspicious in the logs for either Z2M nor hass. The affected devices/entities seem to be different on every restart

MQTT Explorer:

The same device in hass, showing only three discovered entities:

(Made this post after hours of futile debugging)… Seems the issue is related to the mosquitto max_queued_messages setting introduced in v2.0.16. Given I have ~7k mqtt entities in hass, it’s likely that the volume of discovery messages was causing drops. Setting max_queued_messages 0 in mosquitto.conf seems to have helped.

This thread on github tipped me off: messages are no longer retained with 2.0.16+ (with a lot of reained topics?) · Issue #2887 · eclipse/mosquitto · GitHub