njouanin / hbmqtt

MQTT client/broker using Python asynchronous I/O
MIT License
795 stars 188 forks source link

Misc fixes #213

Closed shipmints closed 4 years ago

shipmints commented 4 years ago

Critical correction for unlimited memory consumption building up retained messages for disconnected sessions where QOS is 0. I did not correct the rest of the retained message handling in this go 'round; e.g., messages should be uniquely retained by topic yet every single message is retained. Perhaps someone else will tackle this.

Critical bug fixes for client disconnect calling a deprecated asyncio API where set_exception is no longer supported on tasks. Changed to merely cancel incomplete tasks.

Critical crash fixes for log messages that were invalid due to a race condition when a session handler is detached which forces session references to None.

Added several if self.logger.isEnabledFor(logging.DEBUG): wrappers to improve performance a tiny bit. More could be done here.

HerrMuellerluedenscheid commented 3 years ago

There is a larger design issue with how hbmqtt handles this case which was not addressed in this commit. If I recall correctly, there was a mention of this in the issue. The major issue that this simple change addressed was that hbmqtt consumed memory ad infinitum retaining messages which was clearly not correct and definitely worse than the solution until @njouanin could take a look (or someone else).

So, this workaround fixes a memory leak for qos=0, right? But for qos>=1 the retained messages will still pile up? I'm just trying to understand to problem to come up with a solution.