Skip to content

Commit 9883d92

Browse files
poorbarcodelhotari
authored andcommitted
[fix][ml] Cursor ignores the position that has an empty ack-set if disabled deletionAtBatchIndexLevelEnabled (apache#24406)
(cherry picked from commit 3bd70fd)
1 parent 27e27d3 commit 9883d92

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

managed-ledger/src/main/java/org/apache/bookkeeper/mledger/impl/ManagedCursorImpl.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2377,7 +2377,7 @@ public void asyncDelete(Iterable<Position> positions, AsyncCallbacks.DeleteCallb
23772377
}
23782378
continue;
23792379
}
2380-
if (position.ackSet == null) {
2380+
if (position.ackSet == null || position.ackSet.length == 0) {
23812381
if (batchDeletedIndexes != null) {
23822382
batchDeletedIndexes.remove(position);
23832383
}

managed-ledger/src/test/java/org/apache/bookkeeper/mledger/impl/ManagedCursorTest.java

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5218,5 +5218,20 @@ public void findEntryFailed(ManagedLedgerException exception, Optional<Position>
52185218
assertEquals(positionRef4.get(), position4);
52195219
}
52205220

5221+
@Test
5222+
public void testDeleteBatchedMessageWithEmptyAckSet() throws Exception {
5223+
ManagedLedgerConfig managedLedgerConfig = new ManagedLedgerConfig();
5224+
managedLedgerConfig.setDeletionAtBatchIndexLevelEnabled(false);
5225+
ManagedLedgerImpl ml = (ManagedLedgerImpl) factory.open("testDeleteBatchedMessageWithEmptyAckSet",
5226+
managedLedgerConfig);
5227+
ManagedCursorImpl cursor = (ManagedCursorImpl) ml.openCursor("c1");
5228+
Position position = ml.addEntry(new byte[1]);
5229+
Position positionWithEmptyAckSet =
5230+
new PositionImpl(position.getLedgerId(), position.getEntryId(), new long[]{});
5231+
cursor.delete(positionWithEmptyAckSet);
5232+
assertEquals(cursor.markDeletePosition, position);
5233+
ml.delete();
5234+
}
5235+
52215236
private static final Logger log = LoggerFactory.getLogger(ManagedCursorTest.class);
52225237
}

0 commit comments

Comments
 (0)