If ManagedCursorImpl has been modified as follows, the cursor recovery is 
successfully completed and the topic become available. Is this change 
appropriate?
```diff
--- 
a/managed-ledger/src/main/java/org/apache/bookkeeper/mledger/impl/ManagedCursorImpl.java
+++ 
b/managed-ledger/src/main/java/org/apache/bookkeeper/mledger/impl/ManagedCursorImpl.java
@@ -353,6 +353,9 @@ public class ManagedCursorImpl implements ManagedCursor {
             }
             position = nextExistingLedger != null ? 
PositionImpl.get(nextExistingLedger, -1) : position;
         }
+        if (position.compareTo(ledger.getLastPosition()) > 0) {
+            position = PositionImpl.get(ledger.getLastPosition());
+        }
         log.info("[{}] Cursor {} recovered to position {}", ledger.getName(), 
name, position);

         messagesConsumedCounter = 
-getNumberOfEntries(Range.openClosed(position, ledger.getLastPosition()));
```

[ Full content available at: https://github.com/apache/pulsar/issues/2666 ]
This message was relayed via gitbox.apache.org for [email protected]

Reply via email to