veghlaci05 commented on code in PR #4566: URL: https://github.com/apache/hive/pull/4566#discussion_r1418846446
########## standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/txn/TransactionalRetryProxy.java: ########## @@ -108,23 +110,36 @@ public Object invoke(Object proxy, Method method, Object[] args) throws Throwabl TransactionContext context = null; try { jdbcResource.bindDataSource(transactional); - context = jdbcResource.getTransactionManager().getTransaction(transactional.propagation().value()); + context = jdbcResource.getTransactionManager().getNewTransaction(transactional.propagation().value()); Object result = toCall.execute(); LOG.debug("Successfull method invocation within transactional context: {}, going to commit.", callerId); - jdbcResource.getTransactionManager().commit(context); + if (context.isRollbackOnly()) { + jdbcResource.getTransactionManager().rollback(context); Review Comment: Rollback will throw the following exception in case of trying to rolling back a completed transaction (`AbstractPlatformTransactionManager`): ``` throw new IllegalTransactionStateException( "Transaction is already completed - do not call commit or rollback more than once per transaction"); ``` `setRollbackOnly()` is called to initiate rollback without exception or manual transaction handling. In this case it's an invalid code path if the transaction is completed (committed or rolled back) because it is handled by the "framework". By not putting it inside an if the exception will reveal this invalid setup. -- 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. To unsubscribe, e-mail: gitbox-unsubscr...@hive.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: gitbox-unsubscr...@hive.apache.org For additional commands, e-mail: gitbox-h...@hive.apache.org