This is an automated email from the ASF dual-hosted git repository.

chenhang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/bookkeeper.git


The following commit(s) were added to refs/heads/master by this push:
     new 145ab15894 fix testWriteLac (#3627)
145ab15894 is described below

commit 145ab158944fc28c1b4c3aaa5067d87e846d1fcb
Author: wenbingshen <[email protected]>
AuthorDate: Fri Nov 25 14:27:15 2022 +0800

    fix testWriteLac (#3627)
    
    ### Motivation
    
    testWriteLac recently became flaky-test:
    
https://github.com/apache/bookkeeper/actions/runs/3424530676/jobs/5704307573#logs
    
    1. Before the entry added the journal entry queue, entry.retain() will be 
executed.
    2. So add a callback function to ensure that the entry is verified after 
the entry is executed done in the journal entry queue.
    
    
    ```java
        public void logAddEntry(long ledgerId, long entryId, ByteBuf entry,
                                boolean ackBeforeSync, WriteCallback cb, Object 
ctx)
                throws InterruptedException {
            // Retain entry until it gets written to journal
            entry.retain();
            ......
        }
    ```
---
 .../java/org/apache/bookkeeper/bookie/BookieImplTest.java   | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)

diff --git 
a/bookkeeper-server/src/test/java/org/apache/bookkeeper/bookie/BookieImplTest.java
 
b/bookkeeper-server/src/test/java/org/apache/bookkeeper/bookie/BookieImplTest.java
index a93b5ac3a0..f77830d6da 100644
--- 
a/bookkeeper-server/src/test/java/org/apache/bookkeeper/bookie/BookieImplTest.java
+++ 
b/bookkeeper-server/src/test/java/org/apache/bookkeeper/bookie/BookieImplTest.java
@@ -98,7 +98,18 @@ public class BookieImplTest extends 
BookKeeperClusterTestCase {
                 .when(spyBookie)
                 .createExplicitLACEntry(eq(ledgerId), eq(lacToAdd));
 
-        spyBookie.setExplicitLac(lacToAdd, null, null, masterKey);
+        AtomicBoolean complete = new AtomicBoolean(false);
+        final BookkeeperInternalCallbacks.WriteCallback writeCallback =
+                new BookkeeperInternalCallbacks.WriteCallback() {
+                    @Override
+                    public void writeComplete(int rc, long ledgerId, long 
entryId, BookieId addr, Object ctx) {
+                        complete.set(true);
+                    }
+                };
+
+        spyBookie.setExplicitLac(lacToAdd, writeCallback, null, masterKey);
+
+        Awaitility.await().untilAsserted(() -> assertTrue(complete.get()));
 
         assertEquals(0, lacToAdd.refCnt());
         assertEquals(0, explicitLACEntry.refCnt());

Reply via email to