pvargacl commented on a change in pull request #1474:
URL: https://github.com/apache/hive/pull/1474#discussion_r484516378
##########
File path: ql/src/java/org/apache/hadoop/hive/ql/Driver.java
##########
@@ -488,30 +489,40 @@ private void runInternal(String command, boolean
alreadyCompiled) throws Command
lockAndRespond();
+ int retryShapshotCnt = 0;
+ int maxRetrySnapshotCnt = HiveConf.getIntVar(driverContext.getConf(),
+ HiveConf.ConfVars.HIVE_TXN_MAX_RETRYSNAPSHOT_COUNT);
+
try {
- if (!driverTxnHandler.isValidTxnListState()) {
- LOG.info("Compiling after acquiring locks");
+ while (!driverTxnHandler.isValidTxnListState() && ++retryShapshotCnt
<= maxRetrySnapshotCnt) {
+ LOG.info("Compiling after acquiring locks, attempt #" +
retryShapshotCnt);
// Snapshot was outdated when locks were acquired, hence regenerate
context,
// txn list and retry
// TODO: Lock acquisition should be moved before analyze, this is a
bit hackish.
// Currently, we acquire a snapshot, we compile the query wrt that
snapshot,
// and then, we acquire locks. If snapshot is still valid, we
continue as usual.
// But if snapshot is not valid, we recompile the query.
if (driverContext.isOutdatedTxn()) {
+ LOG.info("Snapshot is outdated, re-initiating transaction ...");
driverContext.getTxnManager().rollbackTxn();
String userFromUGI = DriverUtils.getUserFromUGI(driverContext);
driverContext.getTxnManager().openTxn(context, userFromUGI,
driverContext.getTxnType());
lockAndRespond();
}
+
driverContext.setRetrial(true);
driverContext.getBackupContext().addSubContext(context);
driverContext.getBackupContext().setHiveLocks(context.getHiveLocks());
context = driverContext.getBackupContext();
+
driverContext.getConf().set(ValidTxnList.VALID_TXNS_KEY,
driverContext.getTxnManager().getValidTxns().toString());
+
if (driverContext.getPlan().hasAcidResourcesInQuery()) {
+ compileInternal(context.getCmd(), true);
driverTxnHandler.recordValidWriteIds();
+ driverTxnHandler.setWriteIdForAcidFileSinks();
}
if (!alreadyCompiled) {
Review comment:
I think this code should be removed. If the alreadyCompiled was false,
we already compiled it once line 473. This should not matter when we are in the
invalid snapshot case, you already recompile the query if it is neccessarry
----------------------------------------------------------------
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]