Skip to content

Comments

[fix][client] Producer uses pulsar-client-internal thread to execute callback#21913

Closed
nodece wants to merge 1 commit intoapache:masterfrom
nodece:fix-producer-callback
Closed

[fix][client] Producer uses pulsar-client-internal thread to execute callback#21913
nodece wants to merge 1 commit intoapache:masterfrom
nodece:fix-producer-callback

Conversation

@nodece
Copy link
Member

@nodece nodece commented Jan 17, 2024

Fixes #21900

Motivation

In #21900, I guess the user uses a sync call in the pulsar-client-io callback thread, so throw the timeout exception.

The pulsar-client-io thread is used to communicate between the broker and the client, when pulsar-client-io is stuck, the timeout exception will be thrown.

If we switch from the pulsar-client-io to the pulsar-client-internal thread to execute the callback, #21900 will be fixed.

In the consumer, there's a similar approach:

protected CompletableFuture<Message<T>> internalReceiveAsync() {
CompletableFutureCancellationHandler cancellationHandler = new CompletableFutureCancellationHandler();
CompletableFuture<Message<T>> result = cancellationHandler.createFuture();
internalPinnedExecutor.execute(() -> {
Message<T> message = incomingMessages.poll();
if (message == null) {
expectMoreIncomingMessages();
pendingReceives.add(result);
cancellationHandler.setCancelAction(() -> pendingReceives.remove(result));
} else {
messageProcessed(message);
result.complete(beforeConsume(message));
}
});
return result;
}

Another approach: Please use the same call(sync or async) in your project.

Modifications

  • Producers always use the pulsar-client-internal thread to execute the callback.

Verifying this change

ProducerCallbackThreadTest has been added.

Documentation

  • doc
  • doc-required
  • doc-not-needed
  • doc-complete

…callback

Signed-off-by: Zixuan Liu <nodeces@gmail.com>
@github-actions github-actions bot added the doc-not-needed Your PR changes do not impact docs label Jan 17, 2024
@nodece nodece closed this Jan 17, 2024
@nodece nodece reopened this Jan 17, 2024
@nodece nodece marked this pull request as draft January 17, 2024 13:05
@nodece
Copy link
Member Author

nodece commented Jan 17, 2024

Some tests fail when multiple threads are used to execute callbacks.

@nodece
Copy link
Member Author

nodece commented Jan 17, 2024

/pulsarbot rerun-failure-checks

@nodece nodece closed this Mar 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

doc-not-needed Your PR changes do not impact docs ready-to-test

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] create producer thread stuck

1 participant