pulsar-client-cpp icon indicating copy to clipboard operation
pulsar-client-cpp copied to clipboard

Fix consumer might not subscribe after a reconnection

Open BewareMyPower opened this issue 1 year ago • 0 comments

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:

  1. The consumer's connection is closed (e.g. the keep alive timer failed)
  2. The connection timer is registered on the executor and will trigger the reconnection after 100ms
  3. 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.

BewareMyPower avatar Jul 31 '24 13:07 BewareMyPower