pulsar-client-cpp
pulsar-client-cpp copied to clipboard
Fix consumer might not subscribe after a reconnection
Fixes https://github.com/apache/pulsar-client-cpp/issues/436
Motivation
When a consumer starts grabbing the connection, it registers a timer after the operation timeout. When that timer is expired, it will fail the connection and cancel the connection timer. However, it results a race condition that:
- The consumer's connection is closed (e.g. the keep alive timer failed)
- The connection timer is registered on the executor and will trigger the reconnection after 100ms
- The connection timer is cancelled, then the reconnection won't start.
Modifications
Cancel the creationTimer_ once HandlerBase#start succeeded first time. Add testReconnectWhenFirstConnectTimedOut to cover this case.