eclipse-paho / eclipse-paho/paho.mqtt.java

Intermittent deadlock due to fix for #719

Open
#763 13 comments 0 reactions 0 assignees View on GitHub
bug More Information Required
Dominant language
Java
Stars
2.3k
Forks
919
PR merge metrics
No merged PRs in 30d

Description

Please fill out the form below before submitting, thank you!

- [ ] Bug exists Release Version 1.2.2 ( Master Branch)
- [X] Bug exists in MQTTv3 Client on Snapshot Version 1.2.3-SNAPSHOT (Develop Branch)
- [ ] Bug exists in MQTTv5 Client on Snapshot Version 1.2.3-SNAPSHOT (Develop Branch)

If this is a bug regarding the Android Service, please raise the bug here instead: https://github.com/eclipse/paho.mqtt.android/issues/new

Opening this issue based on the comments from @marcostorto in issue #719

--------

We found a nasty side effect of this fix. In our environment we use clean_session=false and the broker (vernemq) can take quite some time to respond to connect message when there are many (100K to 1M) messages waiting to be delivered.
In this case the client never completes the connection as MqttException.REASON_CODE_CONNECTION_LOST is raised before the broker respond to connect message. Retrying connection does not help, we get in a sort of deadlock as subsequent connection attempts fail in the same way.

I would strongly advice to remove this fix until this side effect is resolved, I assume it can happen with other brokers as well

We use alpakka library which uses async client [https://github.com/akka/alpakka/blob/master/mqtt/src/main/scala/akka/stream/alpakka/mqtt/impl/MqttFlowStage.scala#L147]

We can reproduce pretty easily by the following sequence:

connect to vernemq with clean session=false
subscribe to a topic with QOS=1
terminate client
publish few 100Ks messages to this topic (actual number of message to show isssue is somehow dependent on message size, for small message size issue appear >1M messages)
reconnect client to broker using same client id

removing this commit connection completes successfully, with this commit connection fails most of the times (although not always).

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.