@@ -5471,12 +5471,13 @@ public void testInsertRowConcurrently()
54715471 int threads = 4 ;
54725472 CyclicBarrier barrier = new CyclicBarrier (threads );
54735473 ExecutorService executor = newFixedThreadPool (threads );
5474+ long insertTimeoutMillis = getConcurrentInsertTimeout ().toMillis ();
54745475 try (TestTable table = createTableWithOneIntegerColumn ("test_insert" )) {
54755476 String tableName = table .getName ();
54765477
54775478 List <Future <OptionalInt >> futures = IntStream .range (0 , threads )
54785479 .mapToObj (threadNumber -> executor .submit (() -> {
5479- barrier .await (10 , SECONDS );
5480+ barrier .await (insertTimeoutMillis , MILLISECONDS );
54805481 try {
54815482 getQueryRunner ().execute ("INSERT INTO " + tableName + " VALUES (" + threadNumber + ")" );
54825483 return OptionalInt .of (threadNumber );
@@ -5498,7 +5499,7 @@ public void testInsertRowConcurrently()
54985499 .collect (toImmutableList ());
54995500
55005501 List <Integer > values = futures .stream ()
5501- .map (future -> tryGetFutureValue (future , 10 , SECONDS ).orElseThrow (() -> new RuntimeException ("Wait timed out" )))
5502+ .map (future -> tryGetFutureValue (future , ( int ) insertTimeoutMillis , MILLISECONDS ).orElseThrow (() -> new RuntimeException ("Wait timed out" )))
55025503 .filter (OptionalInt ::isPresent )
55035504 .map (OptionalInt ::getAsInt )
55045505 .collect (toImmutableList ());
@@ -5516,7 +5517,7 @@ public void testInsertRowConcurrently()
55165517 }
55175518 finally {
55185519 executor .shutdownNow ();
5519- executor .awaitTermination (10 , SECONDS );
5520+ executor .awaitTermination (insertTimeoutMillis , MILLISECONDS );
55205521 }
55215522 }
55225523
@@ -5526,6 +5527,14 @@ protected void verifyConcurrentInsertFailurePermissible(Exception e)
55265527 throw new AssertionError ("Unexpected concurrent insert failure" , e );
55275528 }
55285529
5530+ protected Duration getConcurrentInsertTimeout ()
5531+ {
5532+ // most often we experienced this test failing due to timeout waiting on the barrier,
5533+ // the reason behind this for pooled connectors is connection timeout,
5534+ // making this timeout adjustable according to connection timeout settings
5535+ return new Duration (10 , SECONDS );
5536+ }
5537+
55295538 // Repeat test with invocationCount for better test coverage, since the tested aspect is inherently non-deterministic.
55305539 @ RepeatedTest (4 )
55315540 @ Timeout (60 )
0 commit comments