You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@bookkeeper.apache.org by GitBox <gi...@apache.org> on 2023/01/15 09:51:55 UTC

[GitHub] [bookkeeper] horizonzy commented on a diff in pull request #3620: Fix NPE issue during recovery add

horizonzy commented on code in PR #3620:
URL: https://github.com/apache/bookkeeper/pull/3620#discussion_r1070546486


##########
bookkeeper-server/src/test/java/org/apache/bookkeeper/client/PendingAddOpTest.java:
##########
@@ -87,4 +103,70 @@ 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);
+        lh.pendingAddOps.add(op);

Review Comment:
   Why add same `PendingAddOp` twice to the `pendingAddOps queue`.



##########
bookkeeper-server/src/test/java/org/apache/bookkeeper/client/PendingAddOpTest.java:
##########
@@ -87,4 +103,70 @@ 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);
+        lh.pendingAddOps.add(op);

Review Comment:
   Why add the same `PendingAddOp` twice to the `pendingAddOps queue`.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@bookkeeper.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org