Skip to content

Commit

Permalink
Rollback changes to LedgerHandle
Browse files Browse the repository at this point in the history
  • Loading branch information
zhaohaidao committed Jan 20, 2023
1 parent 1cf0ba7 commit 7848138
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 29 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1769,7 +1769,7 @@ void handleUnrecoverableErrorDuringAdd(int rc) {
if (getLedgerMetadata().getState() == LedgerMetadata.State.IN_RECOVERY) {
// we should not close ledger if ledger is recovery mode
// otherwise we may lose entry.
executeOrdered(() -> errorOutPendingAdds(rc));
errorOutPendingAdds(rc);
return;
}
LOG.error("Closing ledger {} due to {}", ledgerId, BKException.codeLogger(rc));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,34 +103,6 @@ public void testExecuteAfterCancelled() {
assertNull(op.lh);
}

@Test
public void testLedgerHandleWithDeferredSyncDuringRecoveryAdd() throws Exception {
final BookieId b1 = new BookieSocketAddress("b1", 3181).toBookieId();
final BookieId b2 = new BookieSocketAddress("b2", 3181).toBookieId();
final BookieId b3 = new BookieSocketAddress("b3", 3181).toBookieId();
MockClientContext clientCtx = MockClientContext.create();
Versioned<LedgerMetadata> md = ClientUtil.setupLedger(clientCtx, 0,
LedgerMetadataBuilder.create().withInRecoveryState().newEnsembleEntry(0L,
Lists.newArrayList(b1, b2, b3)));
LedgerHandle lh = new LedgerHandle(clientCtx, 0, md, BookKeeper.DigestType.CRC32C,
ClientUtil.PASSWD, EnumSet.of(WriteFlag.DEFERRED_SYNC));
lh.notifyWriteFailed(0, b1);
AtomicInteger rcHolder = new AtomicInteger(-0xdead);
PendingAddOp op = PendingAddOp.create(
lh, mockClientContext, lh.getCurrentEnsemble(),
payload, EnumSet.of(WriteFlag.DEFERRED_SYNC),
(rc, handle, entryId, qwcLatency, ctx) -> {
rcHolder.set(rc);
}, null).enableRecoveryAdd();
assertSame(lh, op.lh);
op.setEntryId(0);
lh.pendingAddOps.add(op);
lh.clientCtx.getMainWorkerPool().submitOrdered(lh.ledgerId, (Callable<Void>) () -> {
op.run();
return null;
}).get();
}

@Test
public void testReadOnlyLedgerHandleWithNotEnoughBookiesExceptionDuringRecoveryAdd() throws Exception {
final BookieId b1 = new BookieSocketAddress("b1", 3181).toBookieId();
Expand Down

0 comments on commit 7848138

Please sign in to comment.