pvargacl commented on a change in pull request #1688:
URL: https://github.com/apache/hive/pull/1688#discussion_r534383384



##########
File path: 
standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/txn/TxnHandler.java
##########
@@ -5094,6 +5153,99 @@ public void countOpenTxns() throws MetaException {
     }
   }
 
+  /**
+   * Add min history level entry for each generated txn record
+   * @param dbConn Connection
+   * @param txnIds new transaction ids
+   * @deprecated Remove this method when min_history_level table is dropped
+   * @throws SQLException ex
+   */
+  @Deprecated
+  private void addTxnToMinHistoryLevel(Connection dbConn, List<Long> txnIds, 
long minOpenTxnId) throws SQLException {
+    if (!useMinHistoryLevel) {
+      return;
+    }
+    // Need to register minimum open txnid for current transactions into 
MIN_HISTORY table.
+    try (Statement stmt = dbConn.createStatement()) {
+
+      List<String> rows = txnIds.stream().map(txnId -> txnId + ", " + 
minOpenTxnId).collect(Collectors.toList());
+
+      // Insert transaction entries into MIN_HISTORY_LEVEL.
+      List<String> inserts =
+          sqlGenerator.createInsertValuesStmt("\"MIN_HISTORY_LEVEL\" 
(\"MHL_TXNID\", \"MHL_MIN_OPEN_TXNID\")", rows);
+      for (String insert : inserts) {
+        LOG.debug("Going to execute insert <" + insert + ">");
+        stmt.execute(insert);
+      }
+      LOG.info("Added entries to MIN_HISTORY_LEVEL for current txns: (" + 
txnIds + ") with min_open_txn: " + minOpenTxnId);
+    } catch (SQLException e) {
+      if (dbProduct.isTableNotExists(e)) {
+        // If the table does not exists anymore, we disable the flag and start 
to work the new way
+        // This enables to switch to the new functionality without a restart
+        useMinHistoryLevel = false;

Review comment:
       The idea is multiple HMS is using the same backend db, you upgrade them 
one by one, the last one changes the schema, all the others change to the new 
functionality, after the first call to min_history table. Do you have any 
practical example of wrapping them in aspect, I do not want to much more code 
complexity just to avoid checking an exception in four places.




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