Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

resolve catalog properties on the error path. #11831

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -40,6 +40,7 @@
import com.facebook.presto.sql.SqlPath;
import com.facebook.presto.sql.planner.Plan;
import com.facebook.presto.sql.tree.Statement;
import com.facebook.presto.transaction.TransactionId;
import com.facebook.presto.transaction.TransactionManager;
import com.facebook.presto.version.EmbedVersion;
import com.google.common.collect.Ordering;
Expand Down Expand Up @@ -414,8 +415,19 @@ private <C> void createQueryInternal(QueryId queryId, SessionContext sessionCont
}
QUERY_STATE_LOG.debug(e, "Query %s failed", session.getQueryId());

TransactionId transactionId;

if (session.getTransactionId().isPresent()) {
transactionId = session.getTransactionId().get();
}
else {
transactionId = transactionManager.beginTransaction(false);
// resolve the catalog session properties in the error path.
session = session.beginTransactionId(transactionId, transactionManager, accessControl);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm concerned about this change. I believe this call can also fail, which would cause an uncaught error in the current code. Also, with the Dispatcher change coming soon, the dispatcher won't even have connectors registered so, there is no way to "resolve" connector sessions properties during this phase of the execution.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So what is the right thing to do here? There are some session properties that are specific to a catalog (they come from the connector but are resolved in catalog scope) and without those e.g. our event listeners do not work.

Is there another way besides a transaction to resolve those?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dain mentioned that he has a bigger patch that would affect that part of the code. I still would like to revisit this problem after those changes go in because they affect consumers of catalog properties.

}

// query failure fails the transaction
session.getTransactionId().ifPresent(transactionManager::fail);
transactionManager.fail(transactionId);

QueryExecution execution = new FailedQueryExecution(
session,
Expand Down