kevinrr888 commented on code in PR #5801:
URL: https://github.com/apache/accumulo/pull/5801#discussion_r2277713057
##########
test/src/main/java/org/apache/accumulo/test/TableOperationsIT.java:
##########
@@ -197,6 +201,47 @@ public void createTable() throws TableExistsException,
AccumuloException,
accumuloClient.tableOperations().delete(tableName);
}
+ @Test
+ public void testDefendAgainstThreadsCreateSameTableNameConcurrently()
+ throws ExecutionException, InterruptedException {
+ ExecutorService pool = Executors.newFixedThreadPool(64);
+ List<Future<String>> futureList;
+ int taskSucceeded;
+ int taskFailed;
+
+ for (int i = 0; i < 30; i++) {
+ String tablename = "t" + i;
+ futureList = new ArrayList<>();
+ taskSucceeded = 0;
+ taskFailed = 0;
+
+ for (int j = 0; j < 10; j++) {
+ Future<String> future = pool.submit(() -> {
+ try {
+ accumuloClient.tableOperations().create(tablename);
+ } catch (TableExistsException e) {
+ return "fail";
+ }
+ return "success";
+ });
+ futureList.add(future);
+ }
Review Comment:
Could potentially introduce a CountDownLatch to be more sure these create
table ops are running concurrently. For example call latch.await() before the
create table op, wait for the number of active threads in the pool to be 10,
then call latch.countDown(). This will release all threads to call create() at
the same time
--
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]