deniskuzZ commented on code in PR #6263:
URL: https://github.com/apache/hive/pull/6263#discussion_r2685038877
##########
iceberg/iceberg-handler/src/test/java/org/apache/iceberg/mr/hive/HiveIcebergStorageHandlerWithEngineBase.java:
##########
@@ -210,4 +225,83 @@ protected void validateBasicStats(Table icebergTable,
String dbName, String tabl
Assert.assertEquals(summary.get(entry.getValue()),
hmsParams.get(entry.getKey()));
}
}
+
+ /**
+ * Executes multiple SQL queries concurrently with controlled
synchronization for testing.
+ *
+ * <p>This method supports two synchronization modes:
+ * <ul>
+ * <li><b>Ext-locking mode</b> ({@code useExtLocking=true}): Queries
execute in strict sequential
+ * order (sql[0], then sql[1], then sql[2], ...) to verify that
external table locking prevents
+ * concurrent execution. Each query waits for its turn before
starting.</li>
+ * <li><b>Barrier synchronization mode</b> ({@code useExtLocking=false}):
Queries execute concurrently,
+ * then commit in order to test optimistic concurrency control and
retry on write conflicts.</li>
+ * </ul>
+ *
+ * <p>Uses {@link TestUtilPhaser} and {@link HiveIcebergStorageHandlerStub}
to coordinate thread
+ * execution order deterministically.
+ *
+ * @param useExtLocking if true, enables external locking mode with
sequential execution;
+ * if false, enables concurrent execution with ordered
commits
+ * @param retryStrategies comma-separated list of Hive query retry
strategies to enable
+ * @param sql array of SQL queries to execute. If single query provided,
it's executed by all threads.
+ * If multiple queries provided, each thread executes sql[i]
where i is the thread index.
+ * @throws Exception if any query execution fails
+ */
+ protected void executeConcurrently(
+ boolean useExtLocking, String retryStrategies, String... sql) throws
Exception {
+
+ int nThreads = sql.length > 1 ? sql.length : 2;
+ TestUtilPhaser testUtilPhaser = TestUtilPhaser.getInstance();
+
+ try {
+ Tasks.range(nThreads)
+ .executeWith(Executors.newFixedThreadPool(nThreads))
Review Comment:
good point! it was the original code
--
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]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]