Skip to content

Commit

Permalink
HIVE-1897 Alter command execution "when HDFS is down" results in holding
Browse files Browse the repository at this point in the history
stale data in MetaStore (Chinna Rao Lalam via namit)



git-svn-id: https://svn.apache.org/repos/asf/hive/trunk@1063060 13f79535-47bb-0310-9956-ffa450edef68
  • Loading branch information
Namit Jain committed Jan 24, 2011
1 parent e203fdd commit 47468bf
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
3 changes: 3 additions & 0 deletions CHANGES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -716,6 +716,9 @@ Trunk - Unreleased
HIVE-1917 CTAS (create-table-as-select) throws exception when showing
results (Ning Zhang via namit)

HIVE-1897 Alter command execution "when HDFS is down" results in holding
stale data in MetaStore (Chinna Rao Lalam via namit)

TESTS

HIVE-1464. improve test query performance
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ public void alterTable(RawStore msdb, Warehouse wh, String dbname,
String newTblLoc = null;
boolean moveData = false;
boolean rename = false;
Table oldt = null;
try {
msdb.openTransaction();
name = name.toLowerCase();
Expand All @@ -90,7 +91,7 @@ public void alterTable(RawStore msdb, Warehouse wh, String dbname,
}

// get old table
Table oldt = msdb.getTable(dbname, name);
oldt = msdb.getTable(dbname, name);
if (oldt == null) {
throw new InvalidOperationException("table " + newt.getDbName() + "."
+ newt.getTableName() + " doesn't exist");
Expand Down Expand Up @@ -194,6 +195,17 @@ public void alterTable(RawStore msdb, Warehouse wh, String dbname,
srcFs.rename(srcPath, destPath);
}
} catch (IOException e) {
boolean revertMetaDataTransaction = false;
try {
msdb.openTransaction();
msdb.alterTable(dbname, newt.getTableName(), oldt);
revertMetaDataTransaction = msdb.commitTransaction();
} catch (Exception e1) {
LOG.error("Reverting metadata opeation failed During HDFS operation failed", e1);
if (!revertMetaDataTransaction) {
msdb.rollbackTransaction();
}
}
throw new InvalidOperationException("Unable to access old location "
+ srcPath + " for table " + dbname + "." + name);
}
Expand Down

0 comments on commit 47468bf

Please sign in to comment.