title: HIVE: Exception: Partition Already Exists while ADDING a NEW Partition to an EXISTING EXTERNAL Table
body: <p>I am getting the below error when the application (java) tries to execute an 'ADD partition' after 'DROP partition IF EXISTS' command in Hive:-</p>
  <p>&quot;&quot;&quot;
  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:&lt;db_name&gt;, tableName:&lt;tbl_name&gt;
  &quot;&quot;&quot;</p>
  <p>Sequence of commands executed:-
  Thread A: USE &lt;db_name&gt;
  Thread B: ALTER TABLE &lt;tbl_name&gt; DROP IF EXISTS PARTITION(<code>i_id</code> ='xxxx', <code>c_id</code> ='yyyy', <code>dt</code> ='zzzz-zz-zz', <code>time</code> ='tttttttt') PURGE
  Thread C: ALTER TABLE &lt;tbl_name&gt; ADD PARTITION(<code>i_id</code> ='xxxx', <code>c_id</code> ='yyyy', <code>dt</code> ='zzzz-zz-zz', <code>time</code> ='tttttttt')</p>
  <p>Note:-
  -Cluster - 5 Mgr nodes (Hive deployed on 3 of them), 3 Utils and 30 DNs
  -There are no signs of any latency issues in ambari-server alerts/logs during the timeframe when this error occurs.
  -It is an EXTERNAL hive table
  -This is a random occurrence (twice a week), associated with separate tables (not the same table everytime). </p>
  <p>Would appreciate any Help to understand what might be causing this issue (Partition ALready Exists) and suggest if I need to look into any other logs to find out the reason behind this.</p>