You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hive.apache.org by ay...@apache.org on 2024/09/10 17:23:06 UTC

(hive) branch master updated: HIVE-28515: Iceberg: Concurrent queries fail during commit with ValidationException. (#5438). (Ayush Saxena, reviewed by Simhadri Govindappa)

This is an automated email from the ASF dual-hosted git repository.

ayushsaxena pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/hive.git


The following commit(s) were added to refs/heads/master by this push:
     new 561b03dc36a HIVE-28515: Iceberg: Concurrent queries fail during commit with ValidationException. (#5438). (Ayush Saxena, reviewed by Simhadri Govindappa)
561b03dc36a is described below

commit 561b03dc36a20d4e3180e4bc4fbd2d6fdaf2fec3
Author: Ayush Saxena <ay...@apache.org>
AuthorDate: Tue Sep 10 22:53:00 2024 +0530

    HIVE-28515: Iceberg: Concurrent queries fail during commit with ValidationException. (#5438). (Ayush Saxena, reviewed by Simhadri Govindappa)
---
 .../iceberg/mr/hive/TestOptimisticRetry.java       | 23 ++++++++++++++++++++++
 .../ql/reexec/ReExecuteOnWriteConflictPlugin.java  |  4 +---
 2 files changed, 24 insertions(+), 3 deletions(-)

diff --git a/iceberg/iceberg-handler/src/test/java/org/apache/iceberg/mr/hive/TestOptimisticRetry.java b/iceberg/iceberg-handler/src/test/java/org/apache/iceberg/mr/hive/TestOptimisticRetry.java
index c9d0bf7e3bc..b86b0765aba 100644
--- a/iceberg/iceberg-handler/src/test/java/org/apache/iceberg/mr/hive/TestOptimisticRetry.java
+++ b/iceberg/iceberg-handler/src/test/java/org/apache/iceberg/mr/hive/TestOptimisticRetry.java
@@ -74,6 +74,29 @@ public class TestOptimisticRetry extends HiveIcebergStorageHandlerWithEngineBase
 
   }
 
+  @Test
+  public void testConcurrentOverwriteAndUpdate() {
+    TestUtilPhaser.getInstance();
+    testTables.createTable(shell, "customers", HiveIcebergStorageHandlerTestUtils.CUSTOMER_SCHEMA,
+        PartitionSpec.unpartitioned(), fileFormat, HiveIcebergStorageHandlerTestUtils.OTHER_CUSTOMER_RECORDS_2,
+        formatVersion);
+    String[] sql =
+        new String[] {"INSERT OVERWRITE table customers SELECT * FROM customers where last_name='Taylor'",
+            "UPDATE customers SET first_name='Changed' WHERE  last_name='Taylor'"};
+
+    // The query shouldn't throw exception but rather retry & commit.
+    Tasks.range(2).executeWith(Executors.newFixedThreadPool(2)).run(i -> {
+      TestUtilPhaser.getInstance().getPhaser().register();
+      init(shell, testTables, temp, executionEngine);
+      HiveConf.setBoolVar(shell.getHiveConf(), HiveConf.ConfVars.HIVE_VECTORIZATION_ENABLED, isVectorized);
+      HiveConf.setVar(shell.getHiveConf(), HiveConf.ConfVars.HIVE_FETCH_TASK_CONVERSION, "none");
+      HiveConf.setVar(shell.getHiveConf(), HiveConf.ConfVars.HIVE_QUERY_REEXECUTION_STRATEGIES, RETRY_STRATEGIES);
+      shell.executeStatement(sql[i]);
+      shell.closeSession();
+    });
+    TestUtilPhaser.destroyInstance();
+  }
+
 
   @Test
   public void testNonOverlappingConcurrent2Updates() {
diff --git a/ql/src/java/org/apache/hadoop/hive/ql/reexec/ReExecuteOnWriteConflictPlugin.java b/ql/src/java/org/apache/hadoop/hive/ql/reexec/ReExecuteOnWriteConflictPlugin.java
index 78c24eee915..f8c52bca0b5 100644
--- a/ql/src/java/org/apache/hadoop/hive/ql/reexec/ReExecuteOnWriteConflictPlugin.java
+++ b/ql/src/java/org/apache/hadoop/hive/ql/reexec/ReExecuteOnWriteConflictPlugin.java
@@ -32,7 +32,6 @@ public class ReExecuteOnWriteConflictPlugin implements IReExecutionPlugin {
   private static final Logger LOG = LoggerFactory.getLogger(ReExecuteOnWriteConflictPlugin.class);
   private static boolean retryPossible;
 
-  private static final Pattern writeConflictErrorPattern = Pattern.compile("^Found.*conflicting.*files(.*)");
   private static final String validationException = "org.apache.iceberg.exceptions.ValidationException";
 
   private static final class LocalHook implements ExecuteWithHookContext {
@@ -44,8 +43,7 @@ public class ReExecuteOnWriteConflictPlugin implements IReExecutionPlugin {
         if (exception != null && exception.getMessage() != null) {
           Throwable cause = Throwables.getRootCause(exception);
 
-          if (cause.getClass().getName().equals(validationException) &&
-              cause.getMessage().matches(writeConflictErrorPattern.pattern())) {
+          if (cause.getClass().getName().equals(validationException)) {
             retryPossible = true;
             LOG.info("Retrying query due to write conflict.");
           }