chenhongSZ opened a new pull request, #23081:
URL: https://github.com/apache/pulsar/pull/23081
### Motivation
we have two brokerUrls(one is dead) in PulsarClient serviceUrl, it is
working well without enabling transactions.
`
# broker test.pulsar.com:6651 is dead
PulsarClient client = PulsarClient.builder()
//.enableTransaction(true)
.serviceUrl("pulsar://test.pulsar.com:6650,test.pulsar.com:6651")
.build();
`
If enabling transactions
`
# broker test.pulsar.com:6651 is dead
PulsarClient client = PulsarClient.builder()
.enableTransaction(true)
.serviceUrl("pulsar://test.pulsar.com:6650,test.pulsar.com:6651")
.build();
`
the following error occurs and the `PulsarClient` init fails, It will not
retry the other brokerUrl
`
2024-07-27T00:52:27,787 - ERROR -
[pulsar-client-io-1-1:TransactionMetaStoreHandler@120] - Transaction meta
handler with transaction coordinator id 14 connection failed.
org.apache.pulsar.client.api.PulsarClientException:
java.util.concurrent.CompletionException:
io.netty.channel.AbstractChannel$AnnotatedConnectException: Connection refused:
test.pulsar.com/127.0.0.1:6651
at
org.apache.pulsar.client.impl.ConnectionPool.lambda$createConnection$14(ConnectionPool.java:311)
~[classes/:?]
at
io.netty.util.concurrent.AbstractEventExecutor.runTask(AbstractEventExecutor.java:173)
~[netty-common-4.1.108.Final.jar:4.1.108.Final]
at
io.netty.util.concurrent.AbstractEventExecutor.safeExecute(AbstractEventExecutor.java:166)
~[netty-common-4.1.108.Final.jar:4.1.108.Final]
at
io.netty.util.concurrent.SingleThreadEventExecutor.runAllTasks(SingleThreadEventExecutor.java:470)
~[netty-common-4.1.108.Final.jar:4.1.108.Final]
at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:566)
~[netty-transport-4.1.108.Final.jar:4.1.108.Final]
at
io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:997)
~[netty-common-4.1.108.Final.jar:4.1.108.Final]
at
io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74)
~[netty-common-4.1.108.Final.jar:4.1.108.Final]
at
io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
~[netty-common-4.1.108.Final.jar:4.1.108.Final]
at java.lang.Thread.run(Thread.java:833) ~[?:?]
Caused by: java.util.concurrent.CompletionException:
io.netty.channel.AbstractChannel$AnnotatedConnectException: Connection refused:
test.pulsar.com/127.0.0.1:6651
at
java.util.concurrent.CompletableFuture.encodeRelay(CompletableFuture.java:368)
~[?:?]
at
java.util.concurrent.CompletableFuture.completeRelay(CompletableFuture.java:377)
~[?:?]
at
java.util.concurrent.CompletableFuture$UniRelay.tryFire(CompletableFuture.java:1097)
~[?:?]
at
java.util.concurrent.CompletableFuture.postComplete(CompletableFuture.java:510)
~[?:?]
at
java.util.concurrent.CompletableFuture.completeExceptionally(CompletableFuture.java:2162)
~[?:?]
at
org.apache.pulsar.common.util.netty.ChannelFutures.lambda$toCompletableFuture$0(ChannelFutures.java:58)
~[classes/:?]
at
io.netty.util.concurrent.DefaultPromise.notifyListener0(DefaultPromise.java:590)
~[netty-common-4.1.108.Final.jar:4.1.108.Final]
at
io.netty.util.concurrent.DefaultPromise.notifyListeners0(DefaultPromise.java:583)
~[netty-common-4.1.108.Final.jar:4.1.108.Final]
at
io.netty.util.concurrent.DefaultPromise.notifyListenersNow(DefaultPromise.java:559)
~[netty-common-4.1.108.Final.jar:4.1.108.Final]
at
io.netty.util.concurrent.DefaultPromise.notifyListeners(DefaultPromise.java:492)
~[netty-common-4.1.108.Final.jar:4.1.108.Final]
at
io.netty.util.concurrent.DefaultPromise.setValue0(DefaultPromise.java:636)
~[netty-common-4.1.108.Final.jar:4.1.108.Final]
at
io.netty.util.concurrent.DefaultPromise.setFailure0(DefaultPromise.java:629)
~[netty-common-4.1.108.Final.jar:4.1.108.Final]
at
io.netty.util.concurrent.DefaultPromise.tryFailure(DefaultPromise.java:118)
~[netty-common-4.1.108.Final.jar:4.1.108.Final]
at
io.netty.channel.nio.AbstractNioChannel$AbstractNioUnsafe.fulfillConnectPromise(AbstractNioChannel.java:326)
~[netty-transport-4.1.108.Final.jar:4.1.108.Final]
at
io.netty.channel.nio.AbstractNioChannel$AbstractNioUnsafe.finishConnect(AbstractNioChannel.java:342)
~[netty-transport-4.1.108.Final.jar:4.1.108.Final]
at
io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:776)
~[netty-transport-4.1.108.Final.jar:4.1.108.Final]
at
io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:724)
~[netty-transport-4.1.108.Final.jar:4.1.108.Final]
at
io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:650)
~[netty-transport-4.1.108.Final.jar:4.1.108.Final]
at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:562)
~[netty-transport-4.1.108.Final.jar:4.1.108.Final]
... 4 more
Caused by: io.netty.channel.AbstractChannel$AnnotatedConnectException:
Connection refused: test.pulsar.com/127.0.0.1:6651
Caused by: java.net.ConnectException: Connection refused
at sun.nio.ch.Net.pollConnect(Native Method) ~[?:?]
at sun.nio.ch.Net.pollConnectNow(Net.java:672) ~[?:?]
at
sun.nio.ch.SocketChannelImpl.finishConnect(SocketChannelImpl.java:946) ~[?:?]
at
io.netty.channel.socket.nio.NioSocketChannel.doFinishConnect(NioSocketChannel.java:337)
~[netty-transport-4.1.108.Final.jar:4.1.108.Final]
at
io.netty.channel.nio.AbstractNioChannel$AbstractNioUnsafe.finishConnect(AbstractNioChannel.java:339)
~[netty-transport-4.1.108.Final.jar:4.1.108.Final]
at
io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:776)
~[netty-transport-4.1.108.Final.jar:4.1.108.Final]
at
io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:724)
~[netty-transport-4.1.108.Final.jar:4.1.108.Final]
at
io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:650)
~[netty-transport-4.1.108.Final.jar:4.1.108.Final]
at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:562)
~[netty-transport-4.1.108.Final.jar:4.1.108.Final]
... 4 more
`
The root cause is that the `TransactionCoordinatorClient` doesn't support
retry.
### Modifications
support retry in `TransactionCoordinatorClient`.
### Documentation
<!-- DO NOT REMOVE THIS SECTION. CHECK THE PROPER BOX ONLY. -->
- [ ] `doc` <!-- Your PR contains doc changes. -->
- [ ] `doc-required` <!-- Your PR changes impact docs and you will update
later -->
- [x] `doc-not-needed` <!-- Your PR changes do not impact docs -->
- [ ] `doc-complete` <!-- Docs have been already added -->
### Matching PR in forked repository
PR in forked repository: <!-- ENTER URL HERE -->
<!--
After opening this PR, the build in apache/pulsar will fail and instructions
will
be provided for opening a PR in the PR author's forked repository.
apache/pulsar pull requests should be first tested in your own fork since
the
apache/pulsar CI based on GitHub Actions has constrained resources and quota.
GitHub Actions provides separate quota for pull requests that are executed
in
a forked repository.
The tests will be run in the forked repository until all PR review comments
have
been handled, the tests pass and the PR is approved by a reviewer.
-->
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]