maheshk114 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_r268476396
########## 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: if the delete directory succeeds and the event reply fails for some other reason, then the event will be replayed again. In the next replay, if it does not finds the directory, cm copy might fail. ---------------------------------------------------------------- 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: us...@infra.apache.org With regards, Apache Git Services