Skip to content

Commit

Permalink
Fixed race condition on deleting topic with active readers (apache#7715)
Browse files Browse the repository at this point in the history
  • Loading branch information
merlimat authored Aug 2, 2020
1 parent 26c49a8 commit 03131fb
Showing 1 changed file with 9 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@
import org.apache.bookkeeper.mledger.ManagedLedgerConfig;
import org.apache.bookkeeper.mledger.ManagedLedgerException;
import org.apache.bookkeeper.mledger.ManagedLedgerException.BadVersionException;
import org.apache.bookkeeper.mledger.ManagedLedgerException.CursorNotFoundException;
import org.apache.bookkeeper.mledger.ManagedLedgerException.InvalidCursorPositionException;
import org.apache.bookkeeper.mledger.ManagedLedgerException.ManagedLedgerAlreadyClosedException;
import org.apache.bookkeeper.mledger.ManagedLedgerException.ManagedLedgerFencedException;
Expand Down Expand Up @@ -2229,7 +2230,14 @@ public void deleteCursorComplete(Object ctx) {

@Override
public void deleteCursorFailed(ManagedLedgerException exception, Object ctx) {
log.warn("[{}] Failed to delete cursor {} : {}", name, cursor, exception);
if (exception instanceof CursorNotFoundException) {
// This could happen if a cursor is getting deleted while we are deleting the topic
// Treating this as a "success" case, since the cursor is gone in any case.
deleteCursorComplete(ctx);
return;
}

log.warn("[{}] Failed to delete cursor {}: {}", name, cursor, exception.getMessage(), exception);
cursorDeleteException.compareAndSet(null, exception);
if (cursorsToDelete.decrementAndGet() == 0) {
// Trigger callback only once
Expand Down

0 comments on commit 03131fb

Please sign in to comment.