BewareMyPower commented on a change in pull request #11159:
URL: https://github.com/apache/pulsar/pull/11159#discussion_r661083640
##########
File path:
pulsar-broker/src/main/java/org/apache/pulsar/broker/service/persistent/PersistentTopic.java
##########
@@ -896,25 +897,60 @@ public void openCursorFailed(ManagedLedgerException
exception, Object ctx) {
// The client will then be able to discard the first
messages if needed.
entryId = msgId.getEntryId() - 1;
}
-
- Position startPosition = new PositionImpl(ledgerId, entryId);
- ManagedCursor cursor = null;
- try {
- cursor = ledger.newNonDurableCursor(startPosition,
subscriptionName, initialPosition);
- } catch (ManagedLedgerException e) {
- return FutureUtil.failedFuture(e);
+ if (ledgerId == -1 && entryId == -1 && readCompacted) {
+ CompactedTopicImpl compactedTopicImpl =
(CompactedTopicImpl) this.compactedTopic;
+ Optional<CompactedTopicImpl.CompactedTopicContext>
optionalCompactedTopicContext;
+ try {
+ optionalCompactedTopicContext =
compactedTopicImpl.getCompactedTopicContext();
+ } catch (ExecutionException e) {
+ subscriptionFuture.completeExceptionally(e.getCause());
+ return subscriptionFuture;
+ } catch (InterruptedException e) {
+ subscriptionFuture.completeExceptionally(e);
+ Thread.currentThread().interrupt();
+ return subscriptionFuture;
+ }
Review comment:
I think it's not proper to use `getCompactedTopicContext`, which calls
`CompletableFuture#get` to wait the future. It's easy to cause deadlock.
--
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]