Index: metastore/src/java/org/apache/hadoop/hive/metastore/ObjectStore.java =================================================================== --- metastore/src/java/org/apache/hadoop/hive/metastore/ObjectStore.java (revision 1449149) +++ metastore/src/java/org/apache/hadoop/hive/metastore/ObjectStore.java (working copy) @@ -2041,23 +2041,44 @@ public void alterPartition(String dbname, String name, List part_vals, Partition newPart) throws InvalidObjectException, MetaException { boolean success = false; + Exception e = null; try { openTransaction(); alterPartitionNoTxn(dbname, name, part_vals, newPart); // commit the changes success = commitTransaction(); + } catch (Exception exception) { + e = exception; } finally { if (!success) { rollbackTransaction(); - throw new MetaException( + MetaException metaException = new MetaException( "The transaction for alter partition did not commit successfully."); + if (e != null) { + metaException.initCause(e); + } + throw metaException; } + + if (e != null) { + if (e instanceof MetaException) { + throw (MetaException)e; + } else if (e instanceof InvalidObjectException) { + throw (InvalidObjectException)e; + } else { + MetaException metaException = new MetaException( + e.getMessage()); + metaException.initCause(e); + throw metaException; + } + } } } public void alterPartitions(String dbname, String name, List> part_vals, List newParts) throws InvalidObjectException, MetaException { boolean success = false; + Exception e = null; try { openTransaction(); Iterator> part_val_itr = part_vals.iterator(); @@ -2067,12 +2088,31 @@ } // commit the changes success = commitTransaction(); + } catch (Exception exception) { + e = exception; } finally { if (!success) { rollbackTransaction(); - throw new MetaException( + MetaException metaException = new MetaException( "The transaction for alter partition did not commit successfully."); + if (e != null) { + metaException.initCause(e); + } + throw metaException; } + + if (e != null) { + if (e instanceof MetaException) { + throw (MetaException)e; + } else if (e instanceof InvalidObjectException) { + throw (InvalidObjectException)e; + } else { + MetaException metaException = new MetaException( + e.getMessage()); + metaException.initCause(e); + throw metaException; + } + } } }