Skip to content

Commit

Permalink
Bump pulsar to 2.10.0.0-rc12 and fix testListOffsetForEmptyRolloverLe…
Browse files Browse the repository at this point in the history
…dger (#1176)

Fixes #1175

The `ManagedLedger#rollCurrentLedgerIfFull` can only work when the managed ledger's state is `LedgerOpened` since apache/pulsar#14664. The corner case described in streamnative/kop#894 is still possible when some entries are sent but not persisted after a rollover and retention works. Therefore, we should still keep the `testListOffsetForEmptyRolloverLedger` to avoid the regression in KoP.

- Bump Pulsar to 2.10.0.0-rc12, which includes apache/pulsar#14664
- Change the managed ledger's state to `LedgerOpened` in `testListOffsetForEmptyRolloverLedger`.

(cherry picked from commit bb37893)
  • Loading branch information
BewareMyPower authored and eolivelli committed May 9, 2022
1 parent 33eeec8 commit 47e332b
Showing 1 changed file with 5 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import static org.testng.Assert.assertTrue;
import static org.testng.Assert.fail;

import java.lang.reflect.Field;
import java.time.Duration;
import java.util.ArrayList;
import java.util.Base64;
Expand Down Expand Up @@ -206,6 +207,10 @@ public void testListOffsetForEmptyRolloverLedger() throws Exception {
}
assertEquals(managedLedger.getLedgersInfo().size(), numLedgers);

// The rollover can only happen when state is LedgerOpened since https://github.com/apache/pulsar/pull/14664
Field stateUpdater = ManagedLedgerImpl.class.getDeclaredField("state");
stateUpdater.setAccessible(true);
stateUpdater.set(managedLedger, ManagedLedgerImpl.State.LedgerOpened);
// Rollover and delete the old ledgers, wait until there is only one empty ledger
managedLedger.getConfig().setRetentionTime(0, TimeUnit.MILLISECONDS);
managedLedger.rollCurrentLedgerIfFull();
Expand Down

0 comments on commit 47e332b

Please sign in to comment.