GeezerVison is showing github.com — [Bug][client] V5 transaction coordinator discovery: listener-aware leader URLs and watch connection handling · Issue #27739 · apache/pulsar
[Bug][client] V5 transaction coordinator discovery: listener-aware leader URLs and watch connection handling #27739Labels type/bugThe PR fixed a bug or issue reported a bug DescriptionSearch before reporting
- I searched in the issues and found nothing similar.
Read release policy
- I understand that unsupported versions don't get bug fixes. I will attempt to reproduce the issue on a supported version of Pulsar client and Pulsar broker.
User environment
Pulsar master (5.1.0-SNAPSHOT): a Java client using the v5 SDK (metadata-store transaction coordinator discovery) against brokers with transactionCoordinatorScalableTopicsEnabled.
Issue Description
These are follow-ups from the review of #27387, which made the direct route of WatchTcAssignmentsDiscovery reachable.
- Listener-aware leader URLs.
TcLeader is built from pulsar.getBrokerServiceUrl()/getBrokerServiceUrlTls(), which is the internal listener, and ServerCnx forwards it unchanged in the assignment snapshot. CommandWatchTcAssignments has no listener field, so the broker can't map it. [fix][client] Distinguish direct TC discovery from proxy pairing #27387 routes a listener-named client's handlers through the service URL. Since [fix][broker] Accept v5 transaction coordinator handshakes only on the elected leader #27580 that only works when the service URL reaches the leader, so a multi-broker cluster used with listenerName can't run v5 transactions. Proposed fix: add an optional advertised_listener_name to CommandWatchTcAssignments, fall back to ServerCnx.listenerName the way lookup does, and resolve each leader's URL for that listener.
TransactionMetaStoreHandler.retargetLeader closes the handler's current channel. In direct mode that channel is the pooled (leader, leader, key) connection that producers and consumers on the broker also use; behind a proxy it's (leader, proxy, key), which is also shared. A leader move therefore disconnects every producer and consumer on that connection. The handler should drop only its own registration, which needs a deregistration method on ClientCnx, or use a dedicated connection key. The NotAllowedException branch of connectionOpened and the registerToConnection failure path close the channel the same way.
- The watch's probe and any-broker pairing are pooled.
ConnectionPool.releaseConnection only closes when pooling is disabled, and with connectionsPerBroker=1 the key is always 0. So after an unsupported probe or pairing, every retry gets the same connection and the same broker back. Each reuse also clears the idle time, because the 30s maximum backoff is shorter than the 60s idle threshold. A dedicated connection key for the watch would fix this.
ClientCnx.idleCheck() doesn't count tcAssignmentsWatchers. A connection used only by the watch is closed as idle every couple of minutes, and the watch reopens. This matters for item 3, because a dedicated watch connection would be used by the watch alone.
Error messages
None. Found in code review.
Reproducing the issue
- Configure a broker with
advertisedListeners=internal:pulsar://<internal-host>:6650,external:pulsar://<public-host>:6650 and connect a v5 client from outside with listenerName=external. The snapshot hands it pulsar://<internal-host>:6650. With [fix][client] Distinguish direct TC discovery from proxy pairing #27387 the handlers route through the service URL, which reaches the leader only when the service URL lands on it.
- With a direct client, let a snapshot move a coordinator to another broker while producers or consumers are connected to the old leader. They are disconnected together with the coordinator handler.
- With a direct client behind a load balancer, during a rolling enable of
transactionCoordinatorScalableTopicsEnabled, the watch probe keeps landing on the same broker after each failure.
Additional information
Review discussion: #27387
Are you willing to submit a PR?
- I'm willing to submit a PR!
MetadataMetadatatype/bugThe PR fixed a bug or issue reported a bug DevelopmentNo branches or pull requestsIssue actions
|