aasha commented on a change in pull request #1232:
URL: https://github.com/apache/hive/pull/1232#discussion_r455490444



##########
File path: 
itests/hive-unit/src/test/java/org/apache/hadoop/hive/ql/parse/BaseReplicationScenariosAcidTables.java
##########
@@ -336,18 +346,30 @@ void verifyInc2Load(String dbName, String lastReplId)
     return txns;
   }
 
-  void allocateWriteIdsForTables(String primaryDbName, Map<String, Long> 
tables,
-                                         TxnStore txnHandler,
-                                         List<Long> txns, HiveConf 
primaryConf) throws Throwable {
+  List<Long> allocateWriteIdsForTablesAndAquireLocks(String primaryDbName, 
Map<String, Long> tables,
+                                                     TxnStore txnHandler,
+                                                     List<Long> txns, HiveConf 
primaryConf) throws Throwable {
     AllocateTableWriteIdsRequest rqst = new AllocateTableWriteIdsRequest();
     rqst.setDbName(primaryDbName);
-
+    List<Long> lockIds = new ArrayList<>();
     for(Map.Entry<String, Long> entry : tables.entrySet()) {
       rqst.setTableName(entry.getKey());
       rqst.setTxnIds(txns);
       txnHandler.allocateTableWriteIds(rqst);
+      for (long txnId : txns) {
+        LockComponent comp = new LockComponent(LockType.SHARED_WRITE, 
LockLevel.TABLE,
+          primaryDbName);
+        comp.setTablename(entry.getKey());
+        comp.setOperationType(DataOperationType.UPDATE);
+        List<LockComponent> components = new ArrayList<LockComponent>(1);
+        components.add(comp);
+        LockRequest lockRequest = new LockRequest(components, "u1", 
"hostname");
+        lockRequest.setTxnid(txnId);
+        lockIds.add(txnHandler.lock(lockRequest).getLockid());

Review comment:
       because if you just do a open txn, it will not acquire a lock




----------------------------------------------------------------
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]



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to