ivankelly commented on a change in pull request #3487: When cursor recovery 
encounters empty cursor ledger, fallback to latest snapshot
URL: https://github.com/apache/pulsar/pull/3487#discussion_r252676681
 
 

 ##########
 File path: 
managed-ledger/src/test/java/org/apache/bookkeeper/mledger/impl/ManagedCursorTest.java
 ##########
 @@ -1091,6 +1091,37 @@ void errorCreatingCursor() throws Exception {
         }
     }
 
+    @Test
+    void failDuringRecoveryWithEmptyLedger() throws Exception {
+        ManagedLedger ledger = factory.open("my_test_ledger");
+        ManagedCursor cursor = ledger.openCursor("cursor");
+
+        ledger.addEntry("entry-1".getBytes());
+        Position p2 = ledger.addEntry("entry-2".getBytes());
+        Position p3 = ledger.addEntry("entry-3".getBytes());
+
+        cursor.markDelete(p2);
+        // Do graceful close so snapshot is forced
+        ledger.close();
+
+        // Re-open
+        ledger = factory.open("my_test_ledger");
+        cursor = ledger.openCursor("cursor");
+        cursor.markDelete(p3);
+
+        // Force-reopen so the recovery will be forced to read from ledger
+        bkc.returnEmptyLedgerAfter(1);
 
 Review comment:
   How is this different to just not calling markDelete on L1110? Surely if you 
don't markDelete the cursor ledger will be empty anyhow.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to