sankarh commented on a change in pull request #578: HIVE-21471: Replicating
conversion of managed to external table leaks HDFS files at target.
URL: https://github.com/apache/hive/pull/578#discussion_r268480500
##########
File path:
standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/HiveAlterHandler.java
##########
@@ -400,7 +405,26 @@ public void alterTable(RawStore msdb, Warehouse wh,
String catName, String dbnam
"Unable to change partition or table. Object " + e.getMessage() + "
does not exist."
+ " Check metastore logs for detailed stack.");
} finally {
- if (!success) {
+ if (success) {
+ // Txn was committed successfully.
+ // If data location is changed in replication flow, then need to
delete the old path.
+ if (replDataLocationChanged) {
+ assert(olddb != null);
+ assert(oldt != null);
+ Path deleteOldDataLoc = new Path(oldt.getSd().getLocation());
+ boolean isAutoPurge =
"true".equalsIgnoreCase(oldt.getParameters().get("auto.purge"));
+ try {
+ wh.deleteDir(deleteOldDataLoc, true, isAutoPurge, olddb);
+ LOG.info("Deleted the old data location: {} for the table: {}",
+ deleteOldDataLoc, dbname + "." + name);
+ } catch (MetaException ex) {
+ // Eat the exception as it doesn't affect the state of existing
tables.
+ // Expect, user to manually drop this path when exception and so
logging a warning.
+ LOG.warn("Unable to delete the old data location: {} for the
table: {}",
Review comment:
I think, if old dir is deleted, then metadata update was already successful.
In this case, during replay of event in next cycle would not set the flag as
the table/partition locations were already pointing to new location under base
dir.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services