merlimat 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_r252691076
##########
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:
It's not the same because the cursor ledger is supposed to always have at
least one entry, which is appended before the ledger id is stored in the
metadata... unless for some reasons that doesn't show up, like in the stack
trace in the description.
----------------------------------------------------------------
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