ashutosh-bapat commented on a change in pull request #581: HIVE-21529 : 
Bootstrap ACID tables as part of incremental dump.
URL: https://github.com/apache/hive/pull/581#discussion_r275232982
 
 

 ##########
 File path: ql/src/java/org/apache/hadoop/hive/ql/exec/repl/ReplDumpTask.java
 ##########
 @@ -137,17 +137,69 @@ private void prepareReturnValues(List<String> values) 
throws SemanticException {
     Utils.writeOutput(values, new Path(work.resultTempPath), conf);
   }
 
+  /**
+   * Decide whether to examine all the tables to dump. We do this if
+   * 1. External tables are going to be part of the dump : In which case we 
need to list their
+   * locations.
+   * 2. External or ACID tables are being bootstrapped for the first time : so 
that we can dump
+   * those tables as a whole.
+   * @return
+   */
+  private boolean shouldDumpExternalTableLocation() {
+    return conf.getBoolVar(HiveConf.ConfVars.REPL_INCLUDE_EXTERNAL_TABLES)
+            && (!conf.getBoolVar(HiveConf.ConfVars.REPL_DUMP_METADATA_ONLY)
+            || 
conf.getBoolVar(HiveConf.ConfVars.REPL_BOOTSTRAP_EXTERNAL_TABLES));
+  }
+
+  private boolean shouldExamineTablesToDump() {
+    return shouldDumpExternalTableLocation() ||
+            conf.getBoolVar(HiveConf.ConfVars.REPL_BOOTSTRAP_ACID_TABLES);
+  }
+
+  private boolean shouldBootstrapDumpTable(Table table) {
+    if (conf.getBoolVar(HiveConf.ConfVars.REPL_BOOTSTRAP_EXTERNAL_TABLES) &&
+            TableType.EXTERNAL_TABLE.equals(table.getTableType())) {
+      return true;
+    }
+
+    if (conf.getBoolVar(HiveConf.ConfVars.REPL_BOOTSTRAP_ACID_TABLES) &&
+           AcidUtils.isTransactionalTable(table)) {
+      return true;
+    }
+
+    return false;
+  }
+
   private Long incrementalDump(Path dumpRoot, DumpMetaData dmd, Path cmRoot, 
Hive hiveDb) throws Exception {
     Long lastReplId;// get list of events matching dbPattern & tblPattern
     // go through each event, and dump out each event to a event-level dump 
dir inside dumproot
+    ValidTxnList validTxnList = null;
+    long waitUntilTime = 0;
+    long bootDumpBeginReplId = -1;
+
+    // If we are bootstrapping ACID tables, we need to perform steps similar 
to a regular
+    // bootstrap (See bootstrapDump() for more details. Only difference here 
is instead of
+    // waiting for the concurrent transactions to finish, we start dumping the 
incremental events
+    // and wait only for the remaining time if any.
+    if (conf.getBoolVar(HiveConf.ConfVars.REPL_BOOTSTRAP_ACID_TABLES)) {
+      bootDumpBeginReplId = 
queryState.getConf().getLong(ReplUtils.LAST_REPL_ID_KEY, -1L);
+      assert (bootDumpBeginReplId >= 0);
+      LOG.info("Dump for bootstrapping ACID tables during an incremental dump 
for db {} and table {}",
+              work.dbNameOrPattern,
+              work.tableNameOrPattern);
+      validTxnList = getTxnMgr().getValidTxns();
 
 Review comment:
   Thanks for the explanation. 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:
us...@infra.apache.org


With regards,
Apache Git Services

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

Reply via email to