DomGarguilo commented on code in PR #5801:
URL: https://github.com/apache/accumulo/pull/5801#discussion_r2279674956


##########
test/src/main/java/org/apache/accumulo/test/TableOperationsIT.java:
##########
@@ -202,6 +204,60 @@ public void createTable() throws TableExistsException, 
AccumuloException,
     accumuloClient.tableOperations().delete(tableName);
   }
 
+  @Test
+  public void testDefendAgainstThreadsCreateSameTableNameConcurrently()
+      throws ExecutionException, InterruptedException {
+
+    ExecutorService pool = Executors.newFixedThreadPool(64);
+
+    for (int i = 0; i < 30; i++) {
+      String tablename = "t" + i;
+      List<Future<String>> futureList = new ArrayList<>();
+
+      CountDownLatch startSignal = new CountDownLatch(1);
+      CountDownLatch doneSignal = new CountDownLatch(10);
+
+      for (int j = 0; j < 10; j++) {
+        Future<String> future = pool.submit(() -> {
+          String result;
+          try {
+            startSignal.await();
+            accumuloClient.tableOperations().create(tablename);
+            result = "success";
+          } catch (TableExistsException e) {
+            result = "fail";
+          } catch (InterruptedException e) {
+            Thread.currentThread().interrupt();
+            result = "fail";
+          } finally {
+            doneSignal.countDown();
+          }
+          return result;
+        });
+        futureList.add(future);
+      }
+
+      startSignal.countDown();

Review Comment:
   I think things might be okay here actually. I think once we get to 
`startSignal.countDown()` all of the 10 threads are guarenteed to be waiting at 
`await()` 



-- 
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