You are viewing a plain text version of this content. The canonical link for it is here.
Posted to gitbox@hive.apache.org by GitBox <gi...@apache.org> on 2021/03/22 15:40:14 UTC

[GitHub] [hive] hmangla98 opened a new pull request #2101: HIVE-24909: Skip the repl events from getting logged in notification log

hmangla98 opened a new pull request #2101:
URL: https://github.com/apache/hive/pull/2101


   What changes were proposed in this pull request?
   Skip the repl events from getting logged in notification log
   
   Why are the changes needed?
   Currently REPL dump events are logged and replicated as a part of replication policy. Whenever one replication cycle completed, we always have one transaction left open on the target corresponding to repl dump operation. This will never be caught up without manually dealing with the transaction on target cluster.
   
   Does this PR introduce any user-facing change?
   No
   
   How was this patch tested?


-- 
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:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: gitbox-unsubscribe@hive.apache.org
For additional commands, e-mail: gitbox-help@hive.apache.org


[GitHub] [hive] hmangla98 commented on a change in pull request #2101: HIVE-24909: Skip the repl events from getting logged in notification log

Posted by GitBox <gi...@apache.org>.
hmangla98 commented on a change in pull request #2101:
URL: https://github.com/apache/hive/pull/2101#discussion_r606733324



##########
File path: ql/src/java/org/apache/hadoop/hive/ql/lockmgr/DbTxnManager.java
##########
@@ -227,6 +228,12 @@ public long openTxn(Context ctx, String user, TxnType txnType) throws LockExcept
     return openTxn(ctx, user, txnType, 0);
   }
 
+  @Override
+  public long openTxn(Context ctx, String user, TxnType txnType, String dbUnderReplication) throws LockException {

Review comment:
       We need some tasks (like startHeartbeat, initialising lock manager, clearing some of variables) to be done in case of normal transactions which is not required in case of repl replayed transactions. So, it would be better if we skip this enhancement. 




-- 
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:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: gitbox-unsubscribe@hive.apache.org
For additional commands, e-mail: gitbox-help@hive.apache.org


[GitHub] [hive] pkumarsinha commented on a change in pull request #2101: HIVE-24909: Skip the repl events from getting logged in notification log

Posted by GitBox <gi...@apache.org>.
pkumarsinha commented on a change in pull request #2101:
URL: https://github.com/apache/hive/pull/2101#discussion_r608039679



##########
File path: ql/src/java/org/apache/hadoop/hive/ql/lockmgr/DbTxnManager.java
##########
@@ -227,6 +228,12 @@ public long openTxn(Context ctx, String user, TxnType txnType) throws LockExcept
     return openTxn(ctx, user, txnType, 0);
   }
 
+  @Override
+  public long openTxn(Context ctx, String user, TxnType txnType, String dbUnderReplication) throws LockException {

Review comment:
       We will just have two paths - one for repl created one for hive repl txn using same interface and they can differ in the payload(txnType/replPolicy/srcTxnIds.
   In current form it would be confusing that which call is supposed to be used in repl and which is not.




-- 
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:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: gitbox-unsubscribe@hive.apache.org
For additional commands, e-mail: gitbox-help@hive.apache.org


[GitHub] [hive] hmangla98 commented on a change in pull request #2101: HIVE-24909: Skip the repl events from getting logged in notification log

Posted by GitBox <gi...@apache.org>.
hmangla98 commented on a change in pull request #2101:
URL: https://github.com/apache/hive/pull/2101#discussion_r605407659



##########
File path: ql/src/java/org/apache/hadoop/hive/ql/lockmgr/DbTxnManager.java
##########
@@ -227,6 +228,12 @@ public long openTxn(Context ctx, String user, TxnType txnType) throws LockExcept
     return openTxn(ctx, user, txnType, 0);
   }
 
+  @Override
+  public long openTxn(Context ctx, String user, TxnType txnType, String dbUnderReplication) throws LockException {

Review comment:
       repl(Open/Rollback/Commit)Txn is specifically for replayed transaction. So, by convention it would be REPL_CREATED transactions. It would be confusion if we introduce txnType in that.




-- 
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:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: gitbox-unsubscribe@hive.apache.org
For additional commands, e-mail: gitbox-help@hive.apache.org


[GitHub] [hive] pkumarsinha commented on a change in pull request #2101: HIVE-24909: Skip the repl events from getting logged in notification log

Posted by GitBox <gi...@apache.org>.
pkumarsinha commented on a change in pull request #2101:
URL: https://github.com/apache/hive/pull/2101#discussion_r608352021



##########
File path: standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/HMSHandler.java
##########
@@ -8400,8 +8408,10 @@ public void commit_txn(CommitTxnRequest rqst) throws TException {
     }
     getTxnHandler().commitTxn(rqst);
     if (listeners != null && !listeners.isEmpty()) {
-      MetaStoreListenerNotifier.notifyEvent(listeners, EventType.COMMIT_TXN,
-          new CommitTxnEvent(rqst.getTxnid(), this));
+      if (!isHiveReplTxn) {
+        MetaStoreListenerNotifier.notifyEvent(listeners, EventType.COMMIT_TXN,
+                new CommitTxnEvent(rqst.getTxnid(), this));
+      }

Review comment:
       if (!isHiveReplTxn) can be moved out




-- 
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:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: gitbox-unsubscribe@hive.apache.org
For additional commands, e-mail: gitbox-help@hive.apache.org


[GitHub] [hive] hmangla98 commented on a change in pull request #2101: HIVE-24909: Skip the repl events from getting logged in notification log

Posted by GitBox <gi...@apache.org>.
hmangla98 commented on a change in pull request #2101:
URL: https://github.com/apache/hive/pull/2101#discussion_r608262506



##########
File path: standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/HMSHandler.java
##########
@@ -8349,8 +8353,12 @@ public long get_latest_txnid_in_conflict(long txnId) throws MetaException {
 
   @Override
   public void commit_txn(CommitTxnRequest rqst) throws TException {
+    boolean isReplayedReplTxn = rqst.isSetReplPolicy() && rqst.isSetTxn_type() &&
+            rqst.getTxn_type() == TxnType.REPL_CREATED;
+    boolean isHiveReplTxn = rqst.isSetReplPolicy()
+            && (!rqst.isSetTxn_type() || (rqst.isSetTxn_type() && rqst.getTxn_type() != TxnType.REPL_CREATED));

Review comment:
       It can be simplified as: 
   boolean isHiveReplTxn = rqst.isSetReplPolicy() &&  rqst.getTxn_type() != TxnType.REPL_CREATED;
   
   Just that for HiveReplTxn, replPolicy would be contain the dbName  and txnType would not be REPL_CREATED.




-- 
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:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: gitbox-unsubscribe@hive.apache.org
For additional commands, e-mail: gitbox-help@hive.apache.org


[GitHub] [hive] hmangla98 commented on a change in pull request #2101: HIVE-24909: Skip the repl events from getting logged in notification log

Posted by GitBox <gi...@apache.org>.
hmangla98 commented on a change in pull request #2101:
URL: https://github.com/apache/hive/pull/2101#discussion_r606732966



##########
File path: standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/txn/TxnHandler.java
##########
@@ -669,8 +669,10 @@ public OpenTxnsResponse openTxns(OpenTxnRequest rqst) throws MetaException {
     }
     List<PreparedStatement> insertPreparedStmts = null;
     TxnType txnType = rqst.isSetTxn_type() ? rqst.getTxn_type() : TxnType.DEFAULT;
+    boolean isReplReplayOperation = rqst.isSetReplPolicy() && txnType == TxnType.REPL_CREATED;

Review comment:
       Post [HIVE-24881](https://github.com/apache/hive/pull/2068), We can have a situation in which txnType == REPL_CREATED and rqst.isSetReplPolicy == false.
   So, we need to make a check for replPolicy as well. 




-- 
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:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: gitbox-unsubscribe@hive.apache.org
For additional commands, e-mail: gitbox-help@hive.apache.org


[GitHub] [hive] kgyrtkirk commented on a change in pull request #2101: HIVE-24909: Skip the repl events from getting logged in notification log

Posted by GitBox <gi...@apache.org>.
kgyrtkirk commented on a change in pull request #2101:
URL: https://github.com/apache/hive/pull/2101#discussion_r609530193



##########
File path: standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/HMSHandler.java
##########
@@ -8582,7 +8582,8 @@ public GetOpenTxnsInfoResponse get_open_txns_info() throws TException {
   public OpenTxnsResponse open_txns(OpenTxnRequest rqst) throws TException {
     OpenTxnsResponse response = getTxnHandler().openTxns(rqst);
     List<Long> txnIds = response.getTxn_ids();
-    if (txnIds != null && listeners != null && !listeners.isEmpty()) {
+    boolean isHiveReplTxn = rqst.isSetReplPolicy() && rqst.getTxn_type() == TxnType.DEFAULT;

Review comment:
       this conditional have been copy pasted to a few places - can we move it into a method?

##########
File path: standalone-metastore/metastore-common/src/main/thrift/hive_metastore.thrift
##########
@@ -1014,6 +1014,7 @@ struct OpenTxnsResponse {
 struct AbortTxnRequest {
     1: required i64 txnid,
     2: optional string replPolicy,
+    3: optional TxnType txn_type = TxnType.DEFAULT,

Review comment:
       we seem to use camelcase in this file - can we continue to do that?
   
   I'm just curious when a field is marked as optional - and also has a default value ; will it still be optional?

##########
File path: ql/src/java/org/apache/hadoop/hive/ql/lockmgr/HiveTxnManager.java
##########
@@ -60,8 +60,8 @@
   * @return The new transaction id
   * @throws LockException if a transaction is already open.
   */
-  long openTxn(Context ctx, String user, TxnType txnType) throws LockException;
 
+ long openTxn(Context ctx, String user, TxnType txnType, String dbUnderReplication) throws LockException;

Review comment:
       I don't feel the argument `dbUnderReplication` strongly connected to the `openTxn` command - I wonder if it would make sense to move it inside the `Context` object - which could enable to not change the signature; and may also come handy later on

##########
File path: standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/HiveMetaStoreClient.java
##########
@@ -3712,16 +3712,17 @@ public long openTxn(String user) throws TException {
   }
 
   @Override
-  public long openTxn(String user, TxnType txnType) throws TException {
-    OpenTxnsResponse txns = openTxnsIntr(user, 1, null, null, txnType);
+  public long openTxn(String user, TxnType txnType, String dbUnderReplication) throws TException {

Review comment:
       are there any drawbacks of keeping the old method and not modifing every callsite by adding a new `null` argument?




-- 
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:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: gitbox-unsubscribe@hive.apache.org
For additional commands, e-mail: gitbox-help@hive.apache.org


[GitHub] [hive] hmangla98 commented on a change in pull request #2101: HIVE-24909: Skip the repl events from getting logged in notification log

Posted by GitBox <gi...@apache.org>.
hmangla98 commented on a change in pull request #2101:
URL: https://github.com/apache/hive/pull/2101#discussion_r616280662



##########
File path: standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/HMSHandler.java
##########
@@ -8582,7 +8582,8 @@ public GetOpenTxnsInfoResponse get_open_txns_info() throws TException {
   public OpenTxnsResponse open_txns(OpenTxnRequest rqst) throws TException {
     OpenTxnsResponse response = getTxnHandler().openTxns(rqst);
     List<Long> txnIds = response.getTxn_ids();
-    if (txnIds != null && listeners != null && !listeners.isEmpty()) {
+    boolean isHiveReplTxn = rqst.isSetReplPolicy() && rqst.getTxn_type() == TxnType.DEFAULT;

Review comment:
       rqst variable can be of different types (OpenTxnRequest/ CommitTxnRequest/ AbortTxnRequest). So, this statement may not be generalised.




-- 
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:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: gitbox-unsubscribe@hive.apache.org
For additional commands, e-mail: gitbox-help@hive.apache.org


[GitHub] [hive] hmangla98 commented on a change in pull request #2101: HIVE-24909: Skip the repl events from getting logged in notification log

Posted by GitBox <gi...@apache.org>.
hmangla98 commented on a change in pull request #2101:
URL: https://github.com/apache/hive/pull/2101#discussion_r605406714



##########
File path: ql/src/java/org/apache/hadoop/hive/ql/exec/ReplTxnTask.java
##########
@@ -106,6 +107,7 @@ public int execute() {
         CommitTxnRequest commitTxnRequest = new CommitTxnRequest(txnId);
         commitTxnRequest.setReplPolicy(work.getReplPolicy());
         commitTxnRequest.setWriteEventInfos(work.getWriteEventInfos());
+        commitTxnRequest.setTxn_type(TxnType.REPL_CREATED);

Review comment:
       For abortTxns, we create a AbortTxnRequest in HiveMetaStoreClient. So, we set it over there in replRollbackTxn.




-- 
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:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: gitbox-unsubscribe@hive.apache.org
For additional commands, e-mail: gitbox-help@hive.apache.org


[GitHub] [hive] hmangla98 commented on a change in pull request #2101: HIVE-24909: Skip the repl events from getting logged in notification log

Posted by GitBox <gi...@apache.org>.
hmangla98 commented on a change in pull request #2101:
URL: https://github.com/apache/hive/pull/2101#discussion_r608262760



##########
File path: standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/HMSHandler.java
##########
@@ -8349,8 +8353,12 @@ public long get_latest_txnid_in_conflict(long txnId) throws MetaException {
 
   @Override
   public void commit_txn(CommitTxnRequest rqst) throws TException {
+    boolean isReplayedReplTxn = rqst.isSetReplPolicy() && rqst.isSetTxn_type() &&

Review comment:
       Will remove it.




-- 
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:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: gitbox-unsubscribe@hive.apache.org
For additional commands, e-mail: gitbox-help@hive.apache.org


[GitHub] [hive] pkumarsinha commented on a change in pull request #2101: HIVE-24909: Skip the repl events from getting logged in notification log

Posted by GitBox <gi...@apache.org>.
pkumarsinha commented on a change in pull request #2101:
URL: https://github.com/apache/hive/pull/2101#discussion_r605521511



##########
File path: standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/txn/TxnHandler.java
##########
@@ -669,8 +669,10 @@ public OpenTxnsResponse openTxns(OpenTxnRequest rqst) throws MetaException {
     }
     List<PreparedStatement> insertPreparedStmts = null;
     TxnType txnType = rqst.isSetTxn_type() ? rqst.getTxn_type() : TxnType.DEFAULT;
+    boolean isReplReplayOperation = rqst.isSetReplPolicy() && txnType == TxnType.REPL_CREATED;

Review comment:
       Then why that check




-- 
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:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: gitbox-unsubscribe@hive.apache.org
For additional commands, e-mail: gitbox-help@hive.apache.org


[GitHub] [hive] hmangla98 commented on a change in pull request #2101: HIVE-24909: Skip the repl events from getting logged in notification log

Posted by GitBox <gi...@apache.org>.
hmangla98 commented on a change in pull request #2101:
URL: https://github.com/apache/hive/pull/2101#discussion_r605528620



##########
File path: standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/txn/TxnHandler.java
##########
@@ -669,8 +669,10 @@ public OpenTxnsResponse openTxns(OpenTxnRequest rqst) throws MetaException {
     }
     List<PreparedStatement> insertPreparedStmts = null;
     TxnType txnType = rqst.isSetTxn_type() ? rqst.getTxn_type() : TxnType.DEFAULT;
+    boolean isReplReplayOperation = rqst.isSetReplPolicy() && txnType == TxnType.REPL_CREATED;

Review comment:
       Yes, we can remove that.




-- 
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:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: gitbox-unsubscribe@hive.apache.org
For additional commands, e-mail: gitbox-help@hive.apache.org


[GitHub] [hive] pkumarsinha merged pull request #2101: HIVE-24909: Skip the repl events from getting logged in notification log

Posted by GitBox <gi...@apache.org>.
pkumarsinha merged pull request #2101:
URL: https://github.com/apache/hive/pull/2101


   


-- 
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:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: gitbox-unsubscribe@hive.apache.org
For additional commands, e-mail: gitbox-help@hive.apache.org


[GitHub] [hive] pkumarsinha commented on a change in pull request #2101: HIVE-24909: Skip the repl events from getting logged in notification log

Posted by GitBox <gi...@apache.org>.
pkumarsinha commented on a change in pull request #2101:
URL: https://github.com/apache/hive/pull/2101#discussion_r621757736



##########
File path: ql/src/java/org/apache/hadoop/hive/ql/lockmgr/DbTxnManager.java
##########
@@ -495,6 +501,7 @@ public void replCommitTxn(CommitTxnRequest rqst) throws LockException {
         // For transaction started internally by repl load command, heartbeat needs to be stopped.
         clearLocksAndHB();
       }
+      rqst.setTxn_type(TxnType.REPL_CREATED);

Review comment:
       rqst object is getting created somewhere else, why not to set the type right there?




-- 
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:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: gitbox-unsubscribe@hive.apache.org
For additional commands, e-mail: gitbox-help@hive.apache.org


[GitHub] [hive] hmangla98 commented on a change in pull request #2101: HIVE-24909: Skip the repl events from getting logged in notification log

Posted by GitBox <gi...@apache.org>.
hmangla98 commented on a change in pull request #2101:
URL: https://github.com/apache/hive/pull/2101#discussion_r621751668



##########
File path: itests/hive-unit/src/test/java/org/apache/hadoop/hive/ql/parse/TestReplicationScenariosExclusiveReplica.java
##########
@@ -74,6 +75,28 @@ public void tearDown() throws Throwable {
     super.tearDown();
   }
 
+  @Test
+  public void testReplOperationsNotCapturedInNotificationLog() throws Throwable {
+    List<String> withClauseOptions = getStagingLocationConfig(replica.repldDir, true);
+    withClauseOptions.add("'" + HiveConf.ConfVars.HIVE_IN_TEST_REPL.varname + "'='" + false + "'");
+    //Perform empty bootstrap dump and load
+    primary.dump(primaryDbName, withClauseOptions);
+    replica.load(replicatedDbName, primaryDbName, withClauseOptions);
+    //Perform empty incremental dump and load so that all db level properties are altered.
+    primary.dump(primaryDbName, withClauseOptions);
+    replica.load(replicatedDbName, primaryDbName, withClauseOptions);
+
+    long lastEventId = primary.getCurrentNotificationEventId().getEventId();
+    primary.dump(primaryDbName, withClauseOptions);
+    long currentEventId = primary.getCurrentNotificationEventId().getEventId();

Review comment:
       Done.




-- 
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:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: gitbox-unsubscribe@hive.apache.org
For additional commands, e-mail: gitbox-help@hive.apache.org


[GitHub] [hive] hmangla98 commented on a change in pull request #2101: HIVE-24909: Skip the repl events from getting logged in notification log

Posted by GitBox <gi...@apache.org>.
hmangla98 commented on a change in pull request #2101:
URL: https://github.com/apache/hive/pull/2101#discussion_r611389837



##########
File path: ql/src/java/org/apache/hadoop/hive/ql/lockmgr/HiveTxnManager.java
##########
@@ -60,8 +60,8 @@
   * @return The new transaction id
   * @throws LockException if a transaction is already open.
   */
-  long openTxn(Context ctx, String user, TxnType txnType) throws LockException;
 
+ long openTxn(Context ctx, String user, TxnType txnType, String dbUnderReplication) throws LockException;

Review comment:
       Moved to context object.




-- 
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:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: gitbox-unsubscribe@hive.apache.org
For additional commands, e-mail: gitbox-help@hive.apache.org


[GitHub] [hive] hmangla98 commented on a change in pull request #2101: HIVE-24909: Skip the repl events from getting logged in notification log

Posted by GitBox <gi...@apache.org>.
hmangla98 commented on a change in pull request #2101:
URL: https://github.com/apache/hive/pull/2101#discussion_r608261804



##########
File path: standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/txn/TxnHandler.java
##########
@@ -958,6 +960,10 @@ private void deleteReplTxnMapEntry(Connection dbConn, long sourceTxnId, String r
   public void abortTxn(AbortTxnRequest rqst) throws NoSuchTxnException, MetaException, TxnAbortedException {
     long txnid = rqst.getTxnid();
     long sourceTxnId = -1;
+    boolean isReplayedReplTxn = rqst.isSetReplPolicy() && rqst.isSetTxn_type()

Review comment:
       Done




-- 
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:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: gitbox-unsubscribe@hive.apache.org
For additional commands, e-mail: gitbox-help@hive.apache.org


[GitHub] [hive] hmangla98 commented on a change in pull request #2101: HIVE-24909: Skip the repl events from getting logged in notification log

Posted by GitBox <gi...@apache.org>.
hmangla98 commented on a change in pull request #2101:
URL: https://github.com/apache/hive/pull/2101#discussion_r608274422



##########
File path: ql/src/java/org/apache/hadoop/hive/ql/Compiler.java
##########
@@ -265,7 +266,15 @@ private void openTransaction(TxnType txnType) throws LockException, CommandProce
     if (DriverUtils.checkConcurrency(driverContext) && startImplicitTxn(driverContext.getTxnManager()) &&
         !driverContext.getTxnManager().isTxnOpen() && txnType != TxnType.COMPACTION) {
       String userFromUGI = DriverUtils.getUserFromUGI(driverContext);
-      driverContext.getTxnManager().openTxn(context, userFromUGI, txnType);
+      boolean isHiveReplTxn = (driverContext.getQueryState().getHiveOperation() != null)

Review comment:
       For some of transactions such as Update_table, there is no corresponding HiveOperation (null in that case). So, it would give NPE if we compare its value.




-- 
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:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: gitbox-unsubscribe@hive.apache.org
For additional commands, e-mail: gitbox-help@hive.apache.org


[GitHub] [hive] hmangla98 commented on a change in pull request #2101: HIVE-24909: Skip the repl events from getting logged in notification log

Posted by GitBox <gi...@apache.org>.
hmangla98 commented on a change in pull request #2101:
URL: https://github.com/apache/hive/pull/2101#discussion_r608259119



##########
File path: ql/src/java/org/apache/hadoop/hive/ql/lockmgr/DbTxnManager.java
##########
@@ -170,6 +170,7 @@ Licensed to the Apache Software Foundation (ASF) under one
   private ScheduledFuture<?> heartbeatTask = null;
   private static final int SHUTDOWN_HOOK_PRIORITY = 0;
   private final ReentrantLock heartbeatTaskLock = new ReentrantLock();
+  private String dbUnderReplication = null;

Review comment:
       This variable is used by commitTxn/AbortTxn to know that this is hiveReplTxn and requires some special handling. It would be again set to null only when commit/AbortTxn event comes for this opened transaction. 




-- 
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:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: gitbox-unsubscribe@hive.apache.org
For additional commands, e-mail: gitbox-help@hive.apache.org


[GitHub] [hive] hmangla98 commented on a change in pull request #2101: HIVE-24909: Skip the repl events from getting logged in notification log

Posted by GitBox <gi...@apache.org>.
hmangla98 commented on a change in pull request #2101:
URL: https://github.com/apache/hive/pull/2101#discussion_r605407659



##########
File path: ql/src/java/org/apache/hadoop/hive/ql/lockmgr/DbTxnManager.java
##########
@@ -227,6 +228,12 @@ public long openTxn(Context ctx, String user, TxnType txnType) throws LockExcept
     return openTxn(ctx, user, txnType, 0);
   }
 
+  @Override
+  public long openTxn(Context ctx, String user, TxnType txnType, String dbUnderReplication) throws LockException {

Review comment:
       repl(Open/Rollback/Commit)Txn is specifically for replayed transaction. So, by convention it would be REPL_CREATED transactions. It would be confusion if we start introducing txnType in that.




-- 
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:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: gitbox-unsubscribe@hive.apache.org
For additional commands, e-mail: gitbox-help@hive.apache.org


[GitHub] [hive] hmangla98 commented on a change in pull request #2101: HIVE-24909: Skip the repl events from getting logged in notification log

Posted by GitBox <gi...@apache.org>.
hmangla98 commented on a change in pull request #2101:
URL: https://github.com/apache/hive/pull/2101#discussion_r618315937



##########
File path: itests/hive-unit/src/test/java/org/apache/hadoop/hive/ql/parse/TestReplicationScenariosAcidTables.java
##########
@@ -809,7 +810,7 @@ public void testOpenTxnEvent() throws Throwable {
             primary.dump(primaryDbName);
 
     long lastReplId = Long.parseLong(bootStrapDump.lastReplicationId);
-    primary.testEventCounts(primaryDbName, lastReplId, null, null, 22);
+    primary.testEventCounts(primaryDbName, lastReplId, null, null, 16);

Review comment:
       primary.testEventCounts would count the number of events captured after the bootstrap was initiated. In this patch, we are not capturing openTxn and commitTxn for hive repl Txns. So, the event count is reduced to 16.




-- 
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:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: gitbox-unsubscribe@hive.apache.org
For additional commands, e-mail: gitbox-help@hive.apache.org


[GitHub] [hive] hmangla98 commented on a change in pull request #2101: HIVE-24909: Skip the repl events from getting logged in notification log

Posted by GitBox <gi...@apache.org>.
hmangla98 commented on a change in pull request #2101:
URL: https://github.com/apache/hive/pull/2101#discussion_r605407790



##########
File path: standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/txn/TxnHandler.java
##########
@@ -669,8 +669,10 @@ public OpenTxnsResponse openTxns(OpenTxnRequest rqst) throws MetaException {
     }
     List<PreparedStatement> insertPreparedStmts = null;
     TxnType txnType = rqst.isSetTxn_type() ? rqst.getTxn_type() : TxnType.DEFAULT;
+    boolean isReplReplayOperation = rqst.isSetReplPolicy() && txnType == TxnType.REPL_CREATED;
+    boolean isReplDumpOrLoadOperation = rqst.isSetReplPolicy() && txnType != TxnType.REPL_CREATED;

Review comment:
       Done




-- 
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:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: gitbox-unsubscribe@hive.apache.org
For additional commands, e-mail: gitbox-help@hive.apache.org


[GitHub] [hive] pkumarsinha commented on a change in pull request #2101: HIVE-24909: Skip the repl events from getting logged in notification log

Posted by GitBox <gi...@apache.org>.
pkumarsinha commented on a change in pull request #2101:
URL: https://github.com/apache/hive/pull/2101#discussion_r605521254



##########
File path: ql/src/java/org/apache/hadoop/hive/ql/lockmgr/DbTxnManager.java
##########
@@ -227,6 +228,12 @@ public long openTxn(Context ctx, String user, TxnType txnType) throws LockExcept
     return openTxn(ctx, user, txnType, 0);
   }
 
+  @Override
+  public long openTxn(Context ctx, String user, TxnType txnType, String dbUnderReplication) throws LockException {

Review comment:
       That's what I mean by enhancement. Like what if it takes txnType as well. Does that help?




-- 
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:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: gitbox-unsubscribe@hive.apache.org
For additional commands, e-mail: gitbox-help@hive.apache.org


[GitHub] [hive] hmangla98 commented on a change in pull request #2101: HIVE-24909: Skip the repl events from getting logged in notification log

Posted by GitBox <gi...@apache.org>.
hmangla98 commented on a change in pull request #2101:
URL: https://github.com/apache/hive/pull/2101#discussion_r607125477



##########
File path: standalone-metastore/metastore-common/src/gen/thrift/gen-javabean/org/apache/hadoop/hive/metastore/api/AbortTxnRequest.java
##########
@@ -13,17 +13,24 @@
 
   private static final org.apache.thrift.protocol.TField TXNID_FIELD_DESC = new org.apache.thrift.protocol.TField("txnid", org.apache.thrift.protocol.TType.I64, (short)1);
   private static final org.apache.thrift.protocol.TField REPL_POLICY_FIELD_DESC = new org.apache.thrift.protocol.TField("replPolicy", org.apache.thrift.protocol.TType.STRING, (short)2);
+  private static final org.apache.thrift.protocol.TField TXN_TYPE_FIELD_DESC = new org.apache.thrift.protocol.TField("txn_type", org.apache.thrift.protocol.TType.I32, (short)3);

Review comment:
       Done




-- 
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:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: gitbox-unsubscribe@hive.apache.org
For additional commands, e-mail: gitbox-help@hive.apache.org


[GitHub] [hive] hmangla98 commented on a change in pull request #2101: HIVE-24909: Skip the repl events from getting logged in notification log

Posted by GitBox <gi...@apache.org>.
hmangla98 commented on a change in pull request #2101:
URL: https://github.com/apache/hive/pull/2101#discussion_r618165959



##########
File path: ql/src/java/org/apache/hadoop/hive/ql/lockmgr/DbTxnManager.java
##########
@@ -525,6 +532,9 @@ public void commitTxn() throws LockException {
       LOG.debug("Committing txn " + JavaUtils.txnIdToString(txnId));
       CommitTxnRequest commitTxnRequest = new CommitTxnRequest(txnId);
       commitTxnRequest.setExclWriteEnabled(conf.getBoolVar(HiveConf.ConfVars.TXN_WRITE_X_LOCK));
+      if (replPolicy != null) {

Review comment:
       Yes, Can be removed.




-- 
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:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: gitbox-unsubscribe@hive.apache.org
For additional commands, e-mail: gitbox-help@hive.apache.org


[GitHub] [hive] pkumarsinha commented on a change in pull request #2101: HIVE-24909: Skip the repl events from getting logged in notification log

Posted by GitBox <gi...@apache.org>.
pkumarsinha commented on a change in pull request #2101:
URL: https://github.com/apache/hive/pull/2101#discussion_r621752489



##########
File path: itests/hive-unit/src/test/java/org/apache/hadoop/hive/ql/parse/TestReplicationScenariosAcidTables.java
##########
@@ -1645,15 +1644,20 @@ public void testHdfsMaxDirItemsLimitDuringIncremental() throws Throwable {
     WarehouseInstance.Tuple incrementalDump2 = primary.run("use " + primaryDbName)
             .dump(primaryDbName, dumpClause);
 
-    eventCount = Integer.parseInt(incrementalDump2.lastReplicationId)
-            - Integer.parseInt(incrementalDump1.lastReplicationId);
-    assertTrue(eventCount > 5);
+    eventCount = getNoOfEventsDumped(incrementalDump2.dumpLocation);
+    assertTrue(eventCount > 5 && eventCount < 1000);

Review comment:
       What is the significance of 5 and 1000 here?




-- 
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:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: gitbox-unsubscribe@hive.apache.org
For additional commands, e-mail: gitbox-help@hive.apache.org


[GitHub] [hive] pkumarsinha commented on a change in pull request #2101: HIVE-24909: Skip the repl events from getting logged in notification log

Posted by GitBox <gi...@apache.org>.
pkumarsinha commented on a change in pull request #2101:
URL: https://github.com/apache/hive/pull/2101#discussion_r605391893



##########
File path: ql/src/java/org/apache/hadoop/hive/ql/exec/ReplTxnTask.java
##########
@@ -106,6 +107,7 @@ public int execute() {
         CommitTxnRequest commitTxnRequest = new CommitTxnRequest(txnId);
         commitTxnRequest.setReplPolicy(work.getReplPolicy());
         commitTxnRequest.setWriteEventInfos(work.getWriteEventInfos());
+        commitTxnRequest.setTxn_type(TxnType.REPL_CREATED);

Review comment:
       We don't need this to be set for AbortTxns?

##########
File path: ql/src/java/org/apache/hadoop/hive/ql/lockmgr/DbTxnManager.java
##########
@@ -227,6 +228,12 @@ public long openTxn(Context ctx, String user, TxnType txnType) throws LockExcept
     return openTxn(ctx, user, txnType, 0);
   }
 
+  @Override
+  public long openTxn(Context ctx, String user, TxnType txnType, String dbUnderReplication) throws LockException {

Review comment:
       Can't we re-use replOpenTxn by enhancing that to take txnType?

##########
File path: standalone-metastore/metastore-common/src/gen/thrift/gen-javabean/org/apache/hadoop/hive/metastore/api/AbortTxnRequest.java
##########
@@ -13,17 +13,24 @@
 
   private static final org.apache.thrift.protocol.TField TXNID_FIELD_DESC = new org.apache.thrift.protocol.TField("txnid", org.apache.thrift.protocol.TType.I64, (short)1);
   private static final org.apache.thrift.protocol.TField REPL_POLICY_FIELD_DESC = new org.apache.thrift.protocol.TField("replPolicy", org.apache.thrift.protocol.TType.STRING, (short)2);
+  private static final org.apache.thrift.protocol.TField TXN_TYPE_FIELD_DESC = new org.apache.thrift.protocol.TField("txn_type", org.apache.thrift.protocol.TType.I32, (short)3);

Review comment:
       you require thrift code generation 

##########
File path: standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/txn/TxnHandler.java
##########
@@ -669,8 +669,10 @@ public OpenTxnsResponse openTxns(OpenTxnRequest rqst) throws MetaException {
     }
     List<PreparedStatement> insertPreparedStmts = null;
     TxnType txnType = rqst.isSetTxn_type() ? rqst.getTxn_type() : TxnType.DEFAULT;
+    boolean isReplReplayOperation = rqst.isSetReplPolicy() && txnType == TxnType.REPL_CREATED;
+    boolean isReplDumpOrLoadOperation = rqst.isSetReplPolicy() && txnType != TxnType.REPL_CREATED;

Review comment:
       isReplDumpOrLoadOperation -> isHiveReplTxn ? 

##########
File path: standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/txn/TxnHandler.java
##########
@@ -669,8 +669,10 @@ public OpenTxnsResponse openTxns(OpenTxnRequest rqst) throws MetaException {
     }
     List<PreparedStatement> insertPreparedStmts = null;
     TxnType txnType = rqst.isSetTxn_type() ? rqst.getTxn_type() : TxnType.DEFAULT;
+    boolean isReplReplayOperation = rqst.isSetReplPolicy() && txnType == TxnType.REPL_CREATED;

Review comment:
       isReplayedReplTxn?
   when we  can have txnType == TxnType.REPL_CREATED but rqst.isSetReplPolicy() == false? 




-- 
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:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: gitbox-unsubscribe@hive.apache.org
For additional commands, e-mail: gitbox-help@hive.apache.org


[GitHub] [hive] hmangla98 commented on a change in pull request #2101: HIVE-24909: Skip the repl events from getting logged in notification log

Posted by GitBox <gi...@apache.org>.
hmangla98 commented on a change in pull request #2101:
URL: https://github.com/apache/hive/pull/2101#discussion_r609542524



##########
File path: standalone-metastore/metastore-common/src/main/thrift/hive_metastore.thrift
##########
@@ -1014,6 +1014,7 @@ struct OpenTxnsResponse {
 struct AbortTxnRequest {
     1: required i64 txnid,
     2: optional string replPolicy,
+    3: optional TxnType txn_type = TxnType.DEFAULT,

Review comment:
       Same syntax we use for openTxnRequest as well. So, I thought we should make it same of this as well.




-- 
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:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: gitbox-unsubscribe@hive.apache.org
For additional commands, e-mail: gitbox-help@hive.apache.org


[GitHub] [hive] hmangla98 commented on a change in pull request #2101: HIVE-24909: Skip the repl events from getting logged in notification log

Posted by GitBox <gi...@apache.org>.
hmangla98 commented on a change in pull request #2101:
URL: https://github.com/apache/hive/pull/2101#discussion_r618164957



##########
File path: itests/hive-unit/src/test/java/org/apache/hadoop/hive/ql/parse/TestReplicationScenariosAcidTables.java
##########
@@ -809,7 +810,7 @@ public void testOpenTxnEvent() throws Throwable {
             primary.dump(primaryDbName);
 
     long lastReplId = Long.parseLong(bootStrapDump.lastReplicationId);
-    primary.testEventCounts(primaryDbName, lastReplId, null, null, 22);
+    primary.testEventCounts(primaryDbName, lastReplId, null, null, 16);

Review comment:
       Two dump and one load operation is not logged that totals to 6 events not logged (OpenTxn and CommitTxn)




-- 
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:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: gitbox-unsubscribe@hive.apache.org
For additional commands, e-mail: gitbox-help@hive.apache.org


[GitHub] [hive] pkumarsinha commented on a change in pull request #2101: HIVE-24909: Skip the repl events from getting logged in notification log

Posted by GitBox <gi...@apache.org>.
pkumarsinha commented on a change in pull request #2101:
URL: https://github.com/apache/hive/pull/2101#discussion_r630392694



##########
File path: ql/src/java/org/apache/hadoop/hive/ql/lockmgr/DbTxnManager.java
##########
@@ -584,6 +600,7 @@ public void rollbackTxn() throws LockException {
           e);
     } finally {
       resetTxnInfo();
+      replPolicy = null;

Review comment:
       same here

##########
File path: ql/src/java/org/apache/hadoop/hive/ql/Context.java
##########
@@ -123,6 +123,8 @@
   // up when we are done.
   private final Set<Context> subContexts;
 
+  private String replPolicy = null;

Review comment:
       nit: default would be null only. 

##########
File path: ql/src/java/org/apache/hadoop/hive/ql/lockmgr/DbTxnManager.java
##########
@@ -539,12 +550,13 @@ public void commitTxn() throws LockException {
     } finally {
       // do all new reset in resetTxnInfo method to make sure that same code is there for replCommitTxn flow.
       resetTxnInfo();
+      replPolicy = null;

Review comment:
       Why not to move this to resetTxnInfo(). All the clean up is anyway there




-- 
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:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: gitbox-unsubscribe@hive.apache.org
For additional commands, e-mail: gitbox-help@hive.apache.org


[GitHub] [hive] pkumarsinha commented on a change in pull request #2101: HIVE-24909: Skip the repl events from getting logged in notification log

Posted by GitBox <gi...@apache.org>.
pkumarsinha commented on a change in pull request #2101:
URL: https://github.com/apache/hive/pull/2101#discussion_r608039679



##########
File path: ql/src/java/org/apache/hadoop/hive/ql/lockmgr/DbTxnManager.java
##########
@@ -227,6 +228,12 @@ public long openTxn(Context ctx, String user, TxnType txnType) throws LockExcept
     return openTxn(ctx, user, txnType, 0);
   }
 
+  @Override
+  public long openTxn(Context ctx, String user, TxnType txnType, String dbUnderReplication) throws LockException {

Review comment:
       We can have two paths - one for repl created one for hive repl txn using same interface and they can differ in the payload(txnType/replPolicy/srcTxnIds.
   In current form it would be confusing that which call is supposed to be used in repl and which is not.




-- 
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:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: gitbox-unsubscribe@hive.apache.org
For additional commands, e-mail: gitbox-help@hive.apache.org


[GitHub] [hive] hmangla98 commented on a change in pull request #2101: HIVE-24909: Skip the repl events from getting logged in notification log

Posted by GitBox <gi...@apache.org>.
hmangla98 commented on a change in pull request #2101:
URL: https://github.com/apache/hive/pull/2101#discussion_r621754207



##########
File path: itests/hive-unit/src/test/java/org/apache/hadoop/hive/ql/parse/TestReplicationScenariosAcidTables.java
##########
@@ -1645,15 +1644,20 @@ public void testHdfsMaxDirItemsLimitDuringIncremental() throws Throwable {
     WarehouseInstance.Tuple incrementalDump2 = primary.run("use " + primaryDbName)
             .dump(primaryDbName, dumpClause);
 
-    eventCount = Integer.parseInt(incrementalDump2.lastReplicationId)
-            - Integer.parseInt(incrementalDump1.lastReplicationId);
-    assertTrue(eventCount > 5);
+    eventCount = getNoOfEventsDumped(incrementalDump2.dumpLocation);
+    assertTrue(eventCount > 5 && eventCount < 1000);

Review comment:
       This test is to assert that no of events dumped cannot be greater than (DFS_MAX_DIR_ITEMS_CONFIG - RESERVED_DIR_ITEMS_COUNT). For this particular run of repl dump (line no. 1645), This value is 1000 which was initially 5 for the previous run. So, no of events should be greater than 5 and less than 1000.




-- 
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:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: gitbox-unsubscribe@hive.apache.org
For additional commands, e-mail: gitbox-help@hive.apache.org


[GitHub] [hive] pkumarsinha commented on a change in pull request #2101: HIVE-24909: Skip the repl events from getting logged in notification log

Posted by GitBox <gi...@apache.org>.
pkumarsinha commented on a change in pull request #2101:
URL: https://github.com/apache/hive/pull/2101#discussion_r608350960



##########
File path: standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/HMSHandler.java
##########
@@ -8349,8 +8353,12 @@ public long get_latest_txnid_in_conflict(long txnId) throws MetaException {
 
   @Override
   public void commit_txn(CommitTxnRequest rqst) throws TException {
+    boolean isReplayedReplTxn = rqst.isSetReplPolicy() && rqst.isSetTxn_type() &&
+            rqst.getTxn_type() == TxnType.REPL_CREATED;
+    boolean isHiveReplTxn = rqst.isSetReplPolicy()
+            && (!rqst.isSetTxn_type() || (rqst.isSetTxn_type() && rqst.getTxn_type() != TxnType.REPL_CREATED));

Review comment:
       In stead of  rqst.getTxn_type() != TxnType.REPL_CREATED you can have an affirmation on default type




-- 
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:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: gitbox-unsubscribe@hive.apache.org
For additional commands, e-mail: gitbox-help@hive.apache.org


[GitHub] [hive] hmangla98 commented on a change in pull request #2101: HIVE-24909: Skip the repl events from getting logged in notification log

Posted by GitBox <gi...@apache.org>.
hmangla98 commented on a change in pull request #2101:
URL: https://github.com/apache/hive/pull/2101#discussion_r605404680



##########
File path: standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/txn/TxnHandler.java
##########
@@ -669,8 +669,10 @@ public OpenTxnsResponse openTxns(OpenTxnRequest rqst) throws MetaException {
     }
     List<PreparedStatement> insertPreparedStmts = null;
     TxnType txnType = rqst.isSetTxn_type() ? rqst.getTxn_type() : TxnType.DEFAULT;
+    boolean isReplReplayOperation = rqst.isSetReplPolicy() && txnType == TxnType.REPL_CREATED;

Review comment:
       We can't have this situation ever.




-- 
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:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: gitbox-unsubscribe@hive.apache.org
For additional commands, e-mail: gitbox-help@hive.apache.org


[GitHub] [hive] hmangla98 commented on a change in pull request #2101: HIVE-24909: Skip the repl events from getting logged in notification log

Posted by GitBox <gi...@apache.org>.
hmangla98 commented on a change in pull request #2101:
URL: https://github.com/apache/hive/pull/2101#discussion_r611389693



##########
File path: standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/HiveMetaStoreClient.java
##########
@@ -3712,16 +3712,17 @@ public long openTxn(String user) throws TException {
   }
 
   @Override
-  public long openTxn(String user, TxnType txnType) throws TException {
-    OpenTxnsResponse txns = openTxnsIntr(user, 1, null, null, txnType);
+  public long openTxn(String user, TxnType txnType, String dbUnderReplication) throws TException {

Review comment:
       Yah! I have changed the methodology.




-- 
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:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: gitbox-unsubscribe@hive.apache.org
For additional commands, e-mail: gitbox-help@hive.apache.org


[GitHub] [hive] hmangla98 commented on a change in pull request #2101: HIVE-24909: Skip the repl events from getting logged in notification log

Posted by GitBox <gi...@apache.org>.
hmangla98 commented on a change in pull request #2101:
URL: https://github.com/apache/hive/pull/2101#discussion_r608257970



##########
File path: ql/src/java/org/apache/hadoop/hive/ql/Compiler.java
##########
@@ -265,7 +266,15 @@ private void openTransaction(TxnType txnType) throws LockException, CommandProce
     if (DriverUtils.checkConcurrency(driverContext) && startImplicitTxn(driverContext.getTxnManager()) &&
         !driverContext.getTxnManager().isTxnOpen() && txnType != TxnType.COMPACTION) {
       String userFromUGI = DriverUtils.getUserFromUGI(driverContext);
-      driverContext.getTxnManager().openTxn(context, userFromUGI, txnType);
+      boolean isHiveReplTxn = (driverContext.getQueryState().getHiveOperation() != null)
+              && (driverContext.getQueryState().getHiveOperation().equals(HiveOperation.REPLDUMP)
+              || driverContext.getQueryState().getHiveOperation().equals(HiveOperation.REPLLOAD));
+      String dbUnderReplication = (isHiveReplTxn) ? PlanUtils.stripQuotes(tree.getChild(0).getText()) : null;
+      if (dbUnderReplication != null) {

Review comment:
       Done




-- 
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:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: gitbox-unsubscribe@hive.apache.org
For additional commands, e-mail: gitbox-help@hive.apache.org


[GitHub] [hive] pkumarsinha commented on a change in pull request #2101: HIVE-24909: Skip the repl events from getting logged in notification log

Posted by GitBox <gi...@apache.org>.
pkumarsinha commented on a change in pull request #2101:
URL: https://github.com/apache/hive/pull/2101#discussion_r608042947



##########
File path: ql/src/java/org/apache/hadoop/hive/ql/Compiler.java
##########
@@ -265,7 +266,15 @@ private void openTransaction(TxnType txnType) throws LockException, CommandProce
     if (DriverUtils.checkConcurrency(driverContext) && startImplicitTxn(driverContext.getTxnManager()) &&
         !driverContext.getTxnManager().isTxnOpen() && txnType != TxnType.COMPACTION) {
       String userFromUGI = DriverUtils.getUserFromUGI(driverContext);
-      driverContext.getTxnManager().openTxn(context, userFromUGI, txnType);
+      boolean isHiveReplTxn = (driverContext.getQueryState().getHiveOperation() != null)

Review comment:
       (driverContext.getQueryState().getHiveOperation() != null) check is not needed

##########
File path: standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/txn/TxnHandler.java
##########
@@ -958,6 +960,10 @@ private void deleteReplTxnMapEntry(Connection dbConn, long sourceTxnId, String r
   public void abortTxn(AbortTxnRequest rqst) throws NoSuchTxnException, MetaException, TxnAbortedException {
     long txnid = rqst.getTxnid();
     long sourceTxnId = -1;
+    boolean isReplayedReplTxn = rqst.isSetReplPolicy() && rqst.isSetTxn_type()

Review comment:
       rqst.isSetTxn_type() check isn't required

##########
File path: standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/HMSHandler.java
##########
@@ -8349,8 +8353,12 @@ public long get_latest_txnid_in_conflict(long txnId) throws MetaException {
 
   @Override
   public void commit_txn(CommitTxnRequest rqst) throws TException {
+    boolean isReplayedReplTxn = rqst.isSetReplPolicy() && rqst.isSetTxn_type() &&
+            rqst.getTxn_type() == TxnType.REPL_CREATED;
+    boolean isHiveReplTxn = rqst.isSetReplPolicy()
+            && (!rqst.isSetTxn_type() || (rqst.isSetTxn_type() && rqst.getTxn_type() != TxnType.REPL_CREATED));

Review comment:
       Could you please explain what are you trying to check?

##########
File path: standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/txn/TxnHandler.java
##########
@@ -958,6 +960,10 @@ private void deleteReplTxnMapEntry(Connection dbConn, long sourceTxnId, String r
   public void abortTxn(AbortTxnRequest rqst) throws NoSuchTxnException, MetaException, TxnAbortedException {
     long txnid = rqst.getTxnid();
     long sourceTxnId = -1;
+    boolean isReplayedReplTxn = rqst.isSetReplPolicy() && rqst.isSetTxn_type()
+            && rqst.getTxn_type() == TxnType.REPL_CREATED;
+    boolean isHiveReplTxn = rqst.isSetReplPolicy()
+            && (!rqst.isSetTxn_type() || (rqst.isSetTxn_type() && rqst.getTxn_type() != TxnType.REPL_CREATED));

Review comment:
       could you pls explain this

##########
File path: standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/HMSHandler.java
##########
@@ -8400,8 +8408,10 @@ public void commit_txn(CommitTxnRequest rqst) throws TException {
     }
     getTxnHandler().commitTxn(rqst);
     if (listeners != null && !listeners.isEmpty()) {
-      MetaStoreListenerNotifier.notifyEvent(listeners, EventType.COMMIT_TXN,
-          new CommitTxnEvent(rqst.getTxnid(), this));
+      if (!isHiveReplTxn) {
+        MetaStoreListenerNotifier.notifyEvent(listeners, EventType.COMMIT_TXN,
+                new CommitTxnEvent(rqst.getTxnid(), this));
+      }

Review comment:
       If you are skipping this event, should you go with next line:
   Optional<CompactionInfo> compactionInfo = getTxnHandler().getCompactionByTxnId(rqst.getTxnid());

##########
File path: ql/src/java/org/apache/hadoop/hive/ql/Compiler.java
##########
@@ -265,7 +266,15 @@ private void openTransaction(TxnType txnType) throws LockException, CommandProce
     if (DriverUtils.checkConcurrency(driverContext) && startImplicitTxn(driverContext.getTxnManager()) &&
         !driverContext.getTxnManager().isTxnOpen() && txnType != TxnType.COMPACTION) {
       String userFromUGI = DriverUtils.getUserFromUGI(driverContext);
-      driverContext.getTxnManager().openTxn(context, userFromUGI, txnType);
+      boolean isHiveReplTxn = (driverContext.getQueryState().getHiveOperation() != null)
+              && (driverContext.getQueryState().getHiveOperation().equals(HiveOperation.REPLDUMP)
+              || driverContext.getQueryState().getHiveOperation().equals(HiveOperation.REPLLOAD));
+      String dbUnderReplication = (isHiveReplTxn) ? PlanUtils.stripQuotes(tree.getChild(0).getText()) : null;
+      if (dbUnderReplication != null) {

Review comment:
       Can isHiveReplTxn be true and dbUnderReplication be null ever? if not, this should be based on check isHiveReplTxn

##########
File path: ql/src/java/org/apache/hadoop/hive/ql/lockmgr/DbTxnManager.java
##########
@@ -170,6 +170,7 @@ Licensed to the Apache Software Foundation (ASF) under one
   private ScheduledFuture<?> heartbeatTask = null;
   private static final int SHUTDOWN_HOOK_PRIORITY = 0;
   private final ReentrantLock heartbeatTaskLock = new ReentrantLock();
+  private String dbUnderReplication = null;

Review comment:
       Why do you need to store it?

##########
File path: standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/HMSHandler.java
##########
@@ -8349,8 +8353,12 @@ public long get_latest_txnid_in_conflict(long txnId) throws MetaException {
 
   @Override
   public void commit_txn(CommitTxnRequest rqst) throws TException {
+    boolean isReplayedReplTxn = rqst.isSetReplPolicy() && rqst.isSetTxn_type() &&

Review comment:
       Why do you need this check - rqst.isSetTxn_type()?




-- 
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:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: gitbox-unsubscribe@hive.apache.org
For additional commands, e-mail: gitbox-help@hive.apache.org


[GitHub] [hive] hmangla98 commented on a change in pull request #2101: HIVE-24909: Skip the repl events from getting logged in notification log

Posted by GitBox <gi...@apache.org>.
hmangla98 commented on a change in pull request #2101:
URL: https://github.com/apache/hive/pull/2101#discussion_r611144947



##########
File path: ql/src/java/org/apache/hadoop/hive/ql/Compiler.java
##########
@@ -265,7 +266,15 @@ private void openTransaction(TxnType txnType) throws LockException, CommandProce
     if (DriverUtils.checkConcurrency(driverContext) && startImplicitTxn(driverContext.getTxnManager()) &&
         !driverContext.getTxnManager().isTxnOpen() && txnType != TxnType.COMPACTION) {
       String userFromUGI = DriverUtils.getUserFromUGI(driverContext);
-      driverContext.getTxnManager().openTxn(context, userFromUGI, txnType);
+      boolean isHiveReplTxn = (driverContext.getQueryState().getHiveOperation() != null)

Review comment:
       Done




-- 
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:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: gitbox-unsubscribe@hive.apache.org
For additional commands, e-mail: gitbox-help@hive.apache.org


[GitHub] [hive] pkumarsinha commented on a change in pull request #2101: HIVE-24909: Skip the repl events from getting logged in notification log

Posted by GitBox <gi...@apache.org>.
pkumarsinha commented on a change in pull request #2101:
URL: https://github.com/apache/hive/pull/2101#discussion_r618069326



##########
File path: ql/src/java/org/apache/hadoop/hive/ql/lockmgr/DbTxnManager.java
##########
@@ -525,6 +532,9 @@ public void commitTxn() throws LockException {
       LOG.debug("Committing txn " + JavaUtils.txnIdToString(txnId));
       CommitTxnRequest commitTxnRequest = new CommitTxnRequest(txnId);
       commitTxnRequest.setExclWriteEnabled(conf.getBoolVar(HiveConf.ConfVars.TXN_WRITE_X_LOCK));
+      if (replPolicy != null) {

Review comment:
       Is default not NULL? This check seems to be not required

##########
File path: itests/hive-unit/src/test/java/org/apache/hadoop/hive/ql/parse/TestReplicationScenariosAcidTables.java
##########
@@ -809,7 +810,7 @@ public void testOpenTxnEvent() throws Throwable {
             primary.dump(primaryDbName);
 
     long lastReplId = Long.parseLong(bootStrapDump.lastReplicationId);
-    primary.testEventCounts(primaryDbName, lastReplId, null, null, 22);
+    primary.testEventCounts(primaryDbName, lastReplId, null, null, 16);

Review comment:
       How many dump open/commit considered here?




-- 
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:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: gitbox-unsubscribe@hive.apache.org
For additional commands, e-mail: gitbox-help@hive.apache.org


[GitHub] [hive] pkumarsinha commented on a change in pull request #2101: HIVE-24909: Skip the repl events from getting logged in notification log

Posted by GitBox <gi...@apache.org>.
pkumarsinha commented on a change in pull request #2101:
URL: https://github.com/apache/hive/pull/2101#discussion_r621751133



##########
File path: itests/hive-unit/src/test/java/org/apache/hadoop/hive/ql/parse/TestReplicationScenariosExclusiveReplica.java
##########
@@ -74,6 +75,28 @@ public void tearDown() throws Throwable {
     super.tearDown();
   }
 
+  @Test
+  public void testReplOperationsNotCapturedInNotificationLog() throws Throwable {
+    List<String> withClauseOptions = getStagingLocationConfig(replica.repldDir, true);
+    withClauseOptions.add("'" + HiveConf.ConfVars.HIVE_IN_TEST_REPL.varname + "'='" + false + "'");
+    //Perform empty bootstrap dump and load
+    primary.dump(primaryDbName, withClauseOptions);
+    replica.load(replicatedDbName, primaryDbName, withClauseOptions);
+    //Perform empty incremental dump and load so that all db level properties are altered.
+    primary.dump(primaryDbName, withClauseOptions);
+    replica.load(replicatedDbName, primaryDbName, withClauseOptions);
+
+    long lastEventId = primary.getCurrentNotificationEventId().getEventId();
+    primary.dump(primaryDbName, withClauseOptions);
+    long currentEventId = primary.getCurrentNotificationEventId().getEventId();

Review comment:
       Probe that there is no event dir created?




-- 
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:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: gitbox-unsubscribe@hive.apache.org
For additional commands, e-mail: gitbox-help@hive.apache.org