Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix no response to client when handleSubscribe because PendingAckHandleImpl init fail #13655

Merged
merged 5 commits into from
Jan 14, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,10 @@ public interface PendingAckReplyCallBack {
* @param pendingAckMetadataEntry {@link PendingAckMetadataEntry} the metadata entry of pending ack
*/
void handleMetadataEntry(PendingAckMetadataEntry pendingAckMetadataEntry);

/**
* Pending ack replay failed callback for pending ack store.
*/
void replayFailed(Throwable t);

}
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,13 @@ public void replayComplete() {
pendingAckHandle.handleCacheRequest();
}

@Override
public void replayFailed(Throwable t) {
synchronized (pendingAckHandle) {
pendingAckHandle.exceptionHandleFuture(t);
}
}

@Override
public void handleMetadataEntry(PendingAckMetadataEntry pendingAckMetadataEntry) {
TxnID txnID = new TxnID(pendingAckMetadataEntry.getTxnidMostBits(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -303,6 +303,8 @@ class PendingAckReplay implements Runnable {
public void run() {
try {
if (cursor.isClosed()) {
pendingAckReplyCallBack.replayFailed(new ManagedLedgerException
.CursorAlreadyClosedException("MLPendingAckStore cursor have been closed."));
log.warn("[{}] MLPendingAckStore cursor have been closed, close replay thread.",
cursor.getManagedLedger().getName());
return;
Expand Down Expand Up @@ -350,6 +352,7 @@ public void run() {
}
}
} catch (Exception e) {
pendingAckReplyCallBack.replayFailed(e);
log.error("[{}] Pending ack recover fail!", subManagedCursor.getManagedLedger().getName(), e);
return;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@ private void initPendingAckStore() {
}).exceptionally(e -> {
acceptQueue.clear();
changeToErrorState();
exceptionHandleFuture(e.getCause());
log.error("PendingAckHandleImpl init fail! TopicName : {}, SubName: {}", topicName, subName, e);
return null;
});
Expand Down Expand Up @@ -889,6 +890,12 @@ public synchronized void completeHandleFuture() {
}
}

public synchronized void exceptionHandleFuture(Throwable t) {
if (!this.pendingAckHandleCompletableFuture.isDone()) {
this.pendingAckHandleCompletableFuture.completeExceptionally(t);
}
}

@Override
public TransactionInPendingAckStats getTransactionInPendingAckStats(TxnID txnID) {
TransactionInPendingAckStats transactionInPendingAckStats = new TransactionInPendingAckStats();
Expand Down