public void commit(TransactionContext context) {
    TransactionContext storedContext = contexts.get();
    if (!storedContext.equals(context)) {
      throw new IllegalStateException();
    }
    try {
      realTransactionManager.commit(context.getTransactionStatus());      
    } finally {
      contexts.unset();
    }
  }
Begins a new transaction or returns an existing, depending on the passed Transaction Propagation.
The created transaction is wrapped into a {@link TransactionContext} which is {@link AutoCloseable} and allows using
the wrapper inside a try-with-resources block.

@param propagation The transaction propagation to use.
standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/txn/jdbc/TransactionContextManager.java