lhotari commented on issue #25936:
URL: https://github.com/apache/pulsar/issues/25936#issuecomment-4625833125
@ashwindakappagari Thanks for reporting this. The simplest way to fix this
is to remove the timeout from producer creation in
`createExclusiveProducerWithRetry`.
I did find a way to make the code to handle the timeout without leaving an
orphan producer, however this doesn't solve the problem:
```java
CompletableFuture<Producer<byte[]>> producerFuture =
client.newProducer().topic(topic)
.accessMode(ProducerAccessMode.Exclusive)
.enableBatching(false)
.blockIfQueueFull(true)
.compressionType(CompressionType.LZ4)
.producerName(producerName)
.createAsync();
CompletableFuture<Producer<byte[]>> timeoutFuture =
producerFuture.orTimeout(10, TimeUnit.SECONDS);
timeoutFuture.exceptionally(t -> {
if (FutureUtil.unwrapCompletionException(t)
instanceof TimeoutException) {
// Since the
producerFuture.thenCompose(Producer::closeAsync);
}
throw FutureUtil.wrapToCompletionException(t);
});
return timeoutFuture.get();
```
That causes more problems than it solves. The producer creation will
continue to be in-flight and retrying the creation will just add another
creation into the queue and that will fail due to the previous one being
created. The Pulsar client doesn't support `.orTimeout`/`.cancel` for the
future returned by `createAsync`.
The future returned by `createAsync` will complete with a timeout exception
after the client's `operationTimeout` (default 30 seconds). It's better to rely
on that.
That means that the fix would simply be `.createAsync().get(10,
TimeUnit.SECONDS)` -> `.createAsync().get()`.
One small detail is that Pulsar client might have a gap in the case where
the successful producer creation would take more than 30 seconds to return back
to the client. That most likely doesn't happen in practice.
--
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]