Uploaded image for project: 'Hive'
  1. Hive
  2. HIVE-24017

"CREATE VIEW" command failing with AlreadyExistsException

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Open
    • Blocker
    • Resolution: Unresolved
    • 2.1.1
    • None
    • HiveServer2, Spark
    • None

    Description

      We are using our custom code to fire 50 concurrent hive view creation queries. The view name is randomly generated for each query and is always unique. We get this stacktrace which we do not get for low concurrency like 20. This is very puzzling, we tried following scenarios to avoid the error:

      1. using "DROP VIEW IF EXISTS" then "CREATE VIEW IF NOT EXISTS"
      2. using "DROP VIEW IF EXISTS" then "CREATE VIEW"
      3. using "CREATE OR REPLACE VIEW"

      We still get the "AlreadyExistsException". Seems like a concurrency/threading issue from either Hive or Spark. We are running our queries in SparkSQL which is internally invoking the Hive libraries. These are one of the query sequence from our custom code :

      // [4] -> [USE default]

      // [5] -> [DROP VIEW IF EXISTS `default`.`w2314287698276073922_generatedsource_46_view_102__m_sparkengine_alltx_allsrc`]
      // [6] -> [CREATE VIEW IF NOT EXISTS `default`.`w2314287698276073922_generatedsource_46_view_102__m_sparkengine_alltx_allsrc` (`a0`, `a1`, `a2`, `a3`) AS SELECT CAST(CAST(5 * CAST(alias.c_custkey AS DECIMAL(18, 0)) AS DECIMAL(28, 0)) AS DECIMAL(18, 0)) as a0, alias.c_name as a1, alias.c_address as a2, alias.c_nationkey as a3 FROM default.dst_sanity_test_customer_hive alias WHERE (CAST(CAST(5 * CAST(alias.c_custkey AS DECIMAL(18, 0)) AS DECIMAL(28, 0)) AS DECIMAL(18, 0)) % 3) = 0]

       

      This is the stacktrace we are getting:-

       

      [com.informatica.sdk.dtm.ExecutionException: [SPARK_1003] Spark task [InfaSpark0] failed with the following error: [User class threw exception: java.lang.reflect.InvocationTargetException
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      at java.lang.reflect.Method.invoke(Method.java:498)
      at com.informatica.compiler.InfaSparkMain$.main(InfaSparkMain.scala:124)
      at com.informatica.compiler.InfaSparkMain.main(InfaSparkMain.scala)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      at java.lang.reflect.Method.invoke(Method.java:498)
      at org.apache.spark.deploy.yarn.ApplicationMaster$$anon$2.run(ApplicationMaster.scala:688)
      Caused by: org.apache.spark.sql.AnalysisException: org.apache.hadoop.hive.ql.metadata.HiveException: AlreadyExistsException(message:Table w2314287698276073922_generatedsource_46_view_102_m_sparkengine_alltx_allsrc already exists);_
      at org.apache.spark.sql.hive.HiveExternalCatalog.withClient(HiveExternalCatalog.scala:108)
      at org.apache.spark.sql.hive.HiveExternalCatalog.createTable(HiveExternalCatalog.scala:238)
      at org.apache.spark.sql.catalyst.catalog.ExternalCatalogWithListener.createTable(ExternalCatalogWithListener.scala:102)
      at org.apache.spark.sql.catalyst.catalog.SessionCatalog.createTable(SessionCatalog.scala:319)
      at org.apache.spark.sql.execution.command.CreateViewCommand.run(views.scala:175)
      at org.apache.spark.sql.execution.command.ExecutedCommandExec.sideEffectResult$lzycompute(commands.scala:70)
      at org.apache.spark.sql.execution.command.ExecutedCommandExec.sideEffectResult(commands.scala:68)
      at org.apache.spark.sql.execution.command.ExecutedCommandExec.executeCollect(commands.scala:79)
      at org.apache.spark.sql.Dataset$$anonfun$6.apply(Dataset.scala:196)
      at org.apache.spark.sql.Dataset$$anonfun$6.apply(Dataset.scala:196)
      at org.apache.spark.sql.Dataset$$anonfun$53.apply(Dataset.scala:3384)
      at org.apache.spark.sql.execution.SQLExecution$$anonfun$withNewExecutionId$1.apply(SQLExecution.scala:78)
      at org.apache.spark.sql.execution.SQLExecution$.withSQLConfPropagated(SQLExecution.scala:125)
      at org.apache.spark.sql.execution.SQLExecution$.withNewExecutionId(SQLExecution.scala:73)
      at org.apache.spark.sql.Dataset.withAction(Dataset.scala:3383)
      at org.apache.spark.sql.Dataset.<init>(Dataset.scala:196)
      at org.apache.spark.sql.Dataset$.ofRows(Dataset.scala:80)
      at org.apache.spark.sql.SparkSession.sql(SparkSession.scala:642)
      at org.apache.spark.sql.SQLContext.sql(SQLContext.scala:694)
      at com.informatica.exec.InfaSpark0$.main(InfaSpark0.scala:55)
      at com.informatica.exec.InfaSpark0.main(InfaSpark0.scala)
      ... 11 more
      Caused by: org.apache.hadoop.hive.ql.metadata.HiveException: AlreadyExistsException(message:Table w2314287698276073922_generatedsource_46_view_102_m_sparkengine_alltx_allsrc already exists)_
      at org.apache.hadoop.hive.ql.metadata.Hive.createTable(Hive.java:864)
      at org.apache.hadoop.hive.ql.metadata.Hive.createTable(Hive.java:872)
      at org.apache.spark.sql.hive.client.HiveClientImpl$$anonfun$createTable$1.apply$mcV$sp(HiveClientImpl.scala:489)
      at org.apache.spark.sql.hive.client.HiveClientImpl$$anonfun$createTable$1.apply(HiveClientImpl.scala:487)
      at org.apache.spark.sql.hive.client.HiveClientImpl$$anonfun$createTable$1.apply(HiveClientImpl.scala:487)
      at org.apache.spark.sql.hive.client.HiveClientImpl$$anonfun$withHiveState$1.apply(HiveClientImpl.scala:283)
      at org.apache.spark.sql.hive.client.HiveClientImpl.liftedTree1$1(HiveClientImpl.scala:221)
      at org.apache.spark.sql.hive.client.HiveClientImpl.retryLocked(HiveClientImpl.scala:220)
      at org.apache.spark.sql.hive.client.HiveClientImpl.withHiveState(HiveClientImpl.scala:266)
      at org.apache.spark.sql.hive.client.HiveClientImpl.createTable(HiveClientImpl.scala:487)
      at org.apache.spark.sql.hive.HiveExternalCatalog$$anonfun$createTable$1.apply$mcV$sp(HiveExternalCatalog.scala:309)
      at org.apache.spark.sql.hive.HiveExternalCatalog$$anonfun$createTable$1.apply(HiveExternalCatalog.scala:238)
      at org.apache.spark.sql.hive.HiveExternalCatalog$$anonfun$createTable$1.apply(HiveExternalCatalog.scala:238)
      at org.apache.spark.sql.hive.HiveExternalCatalog.withClient(HiveExternalCatalog.scala:99)
      ... 31 more
      Caused by: AlreadyExistsException(message:Table w2314287698276073922_generatedsource_46_view_102_m_sparkengine_alltx_allsrc already exists)_
      at org.apache.hadoop.hive.metastore.api.ThriftHiveMetastore$create_table_with_environment_context_result$create_table_with_environment_context_resultStandardScheme.read(ThriftHiveMetastore.java:41631)
      at org.apache.hadoop.hive.metastore.api.ThriftHiveMetastore$create_table_with_environment_context_result$create_table_with_environment_context_resultStandardScheme.read(ThriftHiveMetastore.java:41617)
      at org.apache.hadoop.hive.metastore.api.ThriftHiveMetastore$create_table_with_environment_context_result.read(ThriftHiveMetastore.java:41543)
      at org.apache.thrift.TServiceClient.receiveBase(TServiceClient.java:86)
      at org.apache.hadoop.hive.metastore.api.ThriftHiveMetastore$Client.recv_create_table_with_environment_context(ThriftHiveMetastore.java:1187)
      at org.apache.hadoop.hive.metastore.api.ThriftHiveMetastore$Client.create_table_with_environment_context(ThriftHiveMetastore.java:1173)
      at org.apache.hadoop.hive.metastore.HiveMetaStoreClient.create_table_with_environment_context(HiveMetaStoreClient.java:2549)
      at org.apache.hadoop.hive.ql.metadata.SessionHiveMetaStoreClient.create_table_with_environment_context(SessionHiveMetaStoreClient.java:93)
      at org.apache.hadoop.hive.metastore.HiveMetaStoreClient.createTable(HiveMetaStoreClient.java:814)
      at org.apache.hadoop.hive.metastore.HiveMetaStoreClient.createTable(HiveMetaStoreClient.java:800)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      at java.lang.reflect.Method.invoke(Method.java:498)
      at org.apache.hadoop.hive.metastore.RetryingMetaStoreClient.invoke(RetryingMetaStoreClient.java:154)
      at com.sun.proxy.$Proxy43.createTable(Unknown Source)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      at java.lang.reflect.Method.invoke(Method.java:498)
      at org.apache.hadoop.hive.metastore.HiveMetaStoreClient$SynchronizedHandler.invoke(HiveMetaStoreClient.java:2477)
      at com.sun.proxy.$Proxy43.createTable(Unknown Source)
      at org.apache.hadoop.hive.ql.metadata.Hive.createTable(Hive.java:857)
      ... 44 more

      Attachments

        Activity

          People

            Unassigned Unassigned
            rosaxena Rohit Saxena
            Votes:
            1 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated: