<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>question Re: HIVE: Exception: Partition Already Exists while ADDING a NEW Partition to an EXISTING Table in Support Questions</title>
    <link>https://community.cloudera.com/t5/Support-Questions/HIVE-Exception-Partition-Already-Exists-while-ADDING-a-NEW/m-p/324227#M229316</link>
    <description>&lt;P&gt;&lt;a href="https://community.cloudera.com/t5/user/viewprofilepage/user-id/35418"&gt;@ask_bill_brooks&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks for your reply Bill!!&lt;/P&gt;&lt;P&gt;Though the threads are separate for DROP and ADD partition but I didn't find any race condition/issue in hive-server2 logs when this error occurred.&lt;/P&gt;&lt;P&gt;DROP partition had completed executing before ADD partition command started processing. Also, DROP partition is just a precautionary step in our application (only helpful in case of reruns or duplicate processing) as daily we receive a new file once and respectively a NEW partition gets created for this new file. Hence, I am pretty sure this is not the actual reason.&lt;/P&gt;&lt;P&gt;I assume that this has something to do with Hive retrying internally to execute the ADD partition causing it to fail in one of the retries but I don't have any proof to establish this theory (Nothing in hive-server2 logs as such to determine this could be the reason).&lt;/P&gt;</description>
    <pubDate>Mon, 13 Sep 2021 10:32:51 GMT</pubDate>
    <dc:creator>Priyabrat</dc:creator>
    <dc:date>2021-09-13T10:32:51Z</dc:date>
    <item>
      <title>HIVE: Exception: Partition Already Exists while ADDING a NEW Partition to an EXISTING Table</title>
      <link>https://community.cloudera.com/t5/Support-Questions/HIVE-Exception-Partition-Already-Exists-while-ADDING-a-NEW/m-p/323879#M229232</link>
      <description>&lt;P&gt;Hello all,&lt;/P&gt;&lt;P&gt;I am getting the below error when our application (Java) tries to execute an 'ADD partition' after 'DROP partition IF EXISTS' command in Hive:-&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;"""&lt;/P&gt;&lt;P&gt;Caused by: java.sql.SQLException: Error while processing statement: FAILED: Execution Error, return code 1 from org.apache.hadoop.hive.ql.exec.DDLTask. AlreadyExistsException(message:Partition already exists: Partition(values:[xxxx, yyyy, zzzz-zz-zz, tttttttt], dbName:&amp;lt;db_name&amp;gt;, tableName:&amp;lt;tbl_name&amp;gt;&lt;/P&gt;&lt;P&gt;"""&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Sequence of commands executed:-&lt;/P&gt;&lt;P&gt;Thread A: USE &amp;lt;db_name&amp;gt;&lt;/P&gt;&lt;P&gt;Thread B:&amp;nbsp;ALTER TABLE&amp;nbsp;&amp;lt;tbl_name&amp;gt; DROP IF EXISTS PARTITION(`i_id` ='xxxx', `c_id` ='yyyy', `dt` ='zzzz-zz-zz', `time` ='tttttttt') PURGE&lt;/P&gt;&lt;P&gt;Thread C:&amp;nbsp;ALTER TABLE&amp;nbsp;&amp;lt;tbl_name&amp;gt; ADD PARTITION(`i_id` ='xxxx', `c_id` ='yyyy', `dt` ='zzzz-zz-zz', `time` ='tttttttt')&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Note:-&lt;/P&gt;&lt;P&gt;Cluster - 5 Mgr nodes (Hive deployed on 3 of them), 3 Utils and 30 DNs&lt;/P&gt;&lt;P&gt;There are no signs of any latency issues in ambari-server alerts/logs during the timeframe (+- 30 mins) when the above error/exception occurs.&lt;/P&gt;&lt;P&gt;It is an EXTERNAL hive table&lt;/P&gt;&lt;P&gt;This is a random occurrence (twice a week), associated with separate tables (not the same table everytime).&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Would appreciate any Help to understand what might be causing this issue (Partition ALready Exists) and if I need to look into any other logs to find out the reason behind this.&lt;/P&gt;</description>
      <pubDate>Tue, 07 Sep 2021 15:39:59 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/HIVE-Exception-Partition-Already-Exists-while-ADDING-a-NEW/m-p/323879#M229232</guid>
      <dc:creator>Priyabrat</dc:creator>
      <dc:date>2021-09-07T15:39:59Z</dc:date>
    </item>
    <item>
      <title>Re: HIVE: Exception: Partition Already Exists while ADDING a NEW Partition to an EXISTING Table</title>
      <link>https://community.cloudera.com/t5/Support-Questions/HIVE-Exception-Partition-Already-Exists-while-ADDING-a-NEW/m-p/323968#M229260</link>
      <description>&lt;P&gt;&lt;a href="https://community.cloudera.com/t5/user/viewprofilepage/user-id/91392"&gt;@Priyabrat&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This one is tough to diagnose without access to the Java source code or any other indication that the application has been designed with full regard for how concurrency works when it comes to databases, but I would say just based on the information you've supplied in this post that you want to first eliminate the most obvious possibility—that the problem is a race condition, in which case Thread C is starting to execute before the code in Thread B has fully completed executing.&lt;/P&gt;&lt;P&gt;I'd recommend you rewrite the Java code so that the DDL commands operate sequentially and from a single thread as a first step and see if the "random occurrence" stops happening.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 09 Sep 2021 05:24:06 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/HIVE-Exception-Partition-Already-Exists-while-ADDING-a-NEW/m-p/323968#M229260</guid>
      <dc:creator>ask_bill_brooks</dc:creator>
      <dc:date>2021-09-09T05:24:06Z</dc:date>
    </item>
    <item>
      <title>Re: HIVE: Exception: Partition Already Exists while ADDING a NEW Partition to an EXISTING Table</title>
      <link>https://community.cloudera.com/t5/Support-Questions/HIVE-Exception-Partition-Already-Exists-while-ADDING-a-NEW/m-p/324227#M229316</link>
      <description>&lt;P&gt;&lt;a href="https://community.cloudera.com/t5/user/viewprofilepage/user-id/35418"&gt;@ask_bill_brooks&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks for your reply Bill!!&lt;/P&gt;&lt;P&gt;Though the threads are separate for DROP and ADD partition but I didn't find any race condition/issue in hive-server2 logs when this error occurred.&lt;/P&gt;&lt;P&gt;DROP partition had completed executing before ADD partition command started processing. Also, DROP partition is just a precautionary step in our application (only helpful in case of reruns or duplicate processing) as daily we receive a new file once and respectively a NEW partition gets created for this new file. Hence, I am pretty sure this is not the actual reason.&lt;/P&gt;&lt;P&gt;I assume that this has something to do with Hive retrying internally to execute the ADD partition causing it to fail in one of the retries but I don't have any proof to establish this theory (Nothing in hive-server2 logs as such to determine this could be the reason).&lt;/P&gt;</description>
      <pubDate>Mon, 13 Sep 2021 10:32:51 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/HIVE-Exception-Partition-Already-Exists-while-ADDING-a-NEW/m-p/324227#M229316</guid>
      <dc:creator>Priyabrat</dc:creator>
      <dc:date>2021-09-13T10:32:51Z</dc:date>
    </item>
  </channel>
</rss>

