deniskuzZ commented on a change in pull request #1533:
URL: https://github.com/apache/hive/pull/1533#discussion_r497380399
##########
File path: ql/src/java/org/apache/hadoop/hive/ql/Driver.java
##########
@@ -497,38 +497,41 @@ private void runInternal(String command, boolean
alreadyCompiled) throws Command
HiveConf.ConfVars.HIVE_TXN_MAX_RETRYSNAPSHOT_COUNT);
try {
- while (!driverTxnHandler.isValidTxnListState() && ++retryShapshotCnt
<= maxRetrySnapshotCnt) {
- LOG.info("Re-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, compile the query with that
snapshot, and then - 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();
+ do {
+ driverContext.setOutdatedTxn(false);
+
+ if (!driverTxnHandler.isValidTxnListState()) {
+ LOG.info("Re-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, compile the query with that
snapshot, and then - 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();
+ }
+ // Since we're reusing the compiled plan, we need to update its
start time for current run
+
driverContext.getPlan().setQueryStartTime(driverContext.getQueryDisplay().getQueryStartTime());
}
-
- 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();
- }
- // Since we're reusing the compiled plan, we need to update its
start time for current run
-
driverContext.getPlan().setQueryStartTime(driverContext.getQueryDisplay().getQueryStartTime());
- }
+ } while (driverContext.isOutdatedTxn() && ++retryShapshotCnt <=
maxRetrySnapshotCnt);
Review comment:
added comments
----------------------------------------------------------------
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]