gaozhangmin commented on code in PR #3541:
URL: https://github.com/apache/bookkeeper/pull/3541#discussion_r997677788


##########
bookkeeper-server/src/main/java/org/apache/bookkeeper/replication/Auditor.java:
##########
@@ -1224,22 +1224,37 @@ private CompletableFuture<?> 
publishSuspectedLedgersAsync(Collection<String> mis
         LOG.info("Following ledgers: {} of bookie: {} are identified as 
underreplicated", ledgers, missingBookies);
         numUnderReplicatedLedger.registerSuccessfulValue(ledgers.size());
         LongAdder underReplicatedSize = new LongAdder();
+
         FutureUtils.processList(
                 Lists.newArrayList(ledgers),
-                ledgerId ->
-                    
ledgerManager.readLedgerMetadata(ledgerId).whenComplete((metadata, exception) 
-> {
+                ledgerId -> {
+                    try {
+                        openLedgerNoRecoverySemaphore.acquire();
+                    } catch (InterruptedException e) {
+                        LOG.error("Unable to acquire open ledger operation 
semaphore ", e);
+                        Thread.currentThread().interrupt();

Review Comment:
   You can check it with this test
   ```
   @Test
       public void testProcessListSuccess() throws Exception {
           List<Long> longList = Lists.newArrayList(LongStream.range(0L, 
10L).iterator());
           List<Long> expectedList = Lists.transform(
               longList,
               aLong -> 2 * aLong);
           Semaphore testSemaphore = new Semaphore(5);
           Function<Long, CompletableFuture<Long>> sumFunc = value -> 
FutureUtils.value(2 * value);
           long start = System.currentTimeMillis();
           CompletableFuture<List<Long>> totalFuture = FutureUtils.processList(
               longList,
               num -> {
                   try {
                       testSemaphore.acquire();
                   } catch (InterruptedException e) {
                       Thread.currentThread().interrupt();
                   }
                   return FutureUtils.value(2 * num).whenComplete((v, e) -> {
                      try {
                          Thread.sleep(1000);
                      }  catch (Exception ex) {
   
                      }
                      testSemaphore.release();
                   });
               },
               null);
           assertEquals(expectedList, FutureUtils.result(totalFuture));
           assertTrue(System.currentTimeMillis()-start >= 10*1000);
       }
   ```



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to