You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hive.apache.org by vg...@apache.org on 2019/09/19 18:10:09 UTC

[hive] branch master updated: HIVE-22213: TxnHander cleanupRecords should only clean records belonging to default catalog (Vineet Garg, reviewed by Ashutosh Chauhan)

This is an automated email from the ASF dual-hosted git repository.

vgarg pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/hive.git


The following commit(s) were added to refs/heads/master by this push:
     new 5d1a949  HIVE-22213: TxnHander cleanupRecords should only clean records belonging to default catalog (Vineet Garg, reviewed by Ashutosh Chauhan)
5d1a949 is described below

commit 5d1a9497b98ac47f3643400a8968092b0ac7670a
Author: Vineet Garg <vg...@apache.org>
AuthorDate: Thu Sep 19 11:09:36 2019 -0700

    HIVE-22213: TxnHander cleanupRecords should only clean records belonging to default catalog (Vineet Garg, reviewed by Ashutosh Chauhan)
---
 .../hadoop/hive/metastore/txn/TxnHandler.java      | 22 ++++++++++++++++++++++
 1 file changed, 22 insertions(+)

diff --git a/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/txn/TxnHandler.java b/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/txn/TxnHandler.java
index 83306bf..6029d11 100644
--- a/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/txn/TxnHandler.java
+++ b/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/txn/TxnHandler.java
@@ -88,8 +88,10 @@ import org.apache.hadoop.util.StringUtils;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import static org.apache.hadoop.hive.metastore.DatabaseProduct.MYSQL;
+import static org.apache.hadoop.hive.metastore.utils.MetaStoreUtils.getDefaultCatalog;
 import static org.apache.hadoop.hive.metastore.utils.StringUtils.normalizeIdentifier;
 
+
 import com.google.common.annotations.VisibleForTesting;
 
 /**
@@ -3264,6 +3266,10 @@ abstract class TxnHandler implements TxnStore, TxnStore.MutexAPI {
   @RetrySemantics.Idempotent
   public void cleanupRecords(HiveObjectType type, Database db, Table table,
                              Iterator<Partition> partitionIterator) throws MetaException {
+
+    // cleanup should be done only for objecdts belonging to default catalog
+    final String defaultCatalog = getDefaultCatalog(conf);
+
     try {
       Connection dbConn = null;
       Statement stmt = null;
@@ -3279,6 +3285,11 @@ abstract class TxnHandler implements TxnStore, TxnStore.MutexAPI {
         switch (type) {
           case DATABASE: {
             dbName = db.getName();
+            if(!defaultCatalog.equals(db.getCatalogName())) {
+              LOG.debug("Skipping cleanup because db: " + dbName + " belongs to catalog "
+                  + "other than default catalog: " + db.getCatalogName());
+              return;
+            }
 
             buff.append("delete from TXN_COMPONENTS where tc_database='");
             buff.append(dbName);
@@ -3320,6 +3331,11 @@ abstract class TxnHandler implements TxnStore, TxnStore.MutexAPI {
           case TABLE: {
             dbName = table.getDbName();
             tblName = table.getTableName();
+            if(!defaultCatalog.equals(table.getCatName())) {
+              LOG.debug("Skipping cleanup because table: " + tblName + " belongs to catalog "
+                  + "other than default catalog: " + table.getCatName());
+              return;
+            }
 
             buff.append("delete from TXN_COMPONENTS where tc_database='");
             buff.append(dbName);
@@ -3373,6 +3389,12 @@ abstract class TxnHandler implements TxnStore, TxnStore.MutexAPI {
           case PARTITION: {
             dbName = table.getDbName();
             tblName = table.getTableName();
+            if(!defaultCatalog.equals(table.getCatName())) {
+              LOG.debug("Skipping cleanup because partitions belong to catalog "
+                  + "other than default catalog: " + table.getCatName());
+              return;
+            }
+
             List<FieldSchema> partCols = table.getPartitionKeys();  // partition columns
             List<String> partVals;                                  // partition values
             String partName;