You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@bookkeeper.apache.org by GitBox <gi...@apache.org> on 2018/06/20 15:37:02 UTC

[GitHub] sijie closed pull request #1526: LedgerManagerIteratorTest: avoid ledger collision

sijie closed pull request #1526: LedgerManagerIteratorTest: avoid ledger collision
URL: https://github.com/apache/bookkeeper/pull/1526
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/bookkeeper-server/src/test/java/org/apache/bookkeeper/meta/LedgerManagerIteratorTest.java b/bookkeeper-server/src/test/java/org/apache/bookkeeper/meta/LedgerManagerIteratorTest.java
index 97a0ab731..1bd32c546 100644
--- a/bookkeeper-server/src/test/java/org/apache/bookkeeper/meta/LedgerManagerIteratorTest.java
+++ b/bookkeeper-server/src/test/java/org/apache/bookkeeper/meta/LedgerManagerIteratorTest.java
@@ -52,6 +52,7 @@
 import org.apache.bookkeeper.util.MathUtils;
 import org.apache.bookkeeper.util.ZkUtils;
 import org.apache.bookkeeper.versioning.Version;
+import org.apache.mina.util.ConcurrentHashSet;
 import org.apache.zookeeper.CreateMode;
 import org.apache.zookeeper.ZooDefs;
 import org.junit.After;
@@ -414,6 +415,7 @@ public void checkConcurrentModifications() throws Throwable {
         final long start = MathUtils.nowInNano();
         final CountDownLatch latch = new CountDownLatch(1);
         ArrayList<Thread> threads = new ArrayList<>();
+        final ConcurrentHashSet<Long> createdLedgers = new ConcurrentHashSet<>();
         for (int i = 0; i < numWriters; ++i) {
             Thread thread = new Thread(safeWrapper(() -> {
                 LedgerManager writerLM = getIndependentLedgerManager();
@@ -431,7 +433,7 @@ public void checkConcurrentModifications() throws Throwable {
                         if (!longRange) {
                             candidate %= 1000000;
                         }
-                    } while (mustExist.contains(candidate));
+                    } while (mustExist.contains(candidate) || !createdLedgers.add(candidate));
                     try {
                         createLedger(writerLM, candidate, Optional.empty());
                         removeLedger(writerLM, candidate, Optional.empty());


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services