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

sql: internal executor is very confusing about managing transaction state #78998

Closed
rafiss opened this issue Mar 29, 2022 · 5 comments · Fixed by #82477
Closed

sql: internal executor is very confusing about managing transaction state #78998

rafiss opened this issue Mar 29, 2022 · 5 comments · Fixed by #82477
Assignees
Labels
A-sql-executor SQL txn logic C-enhancement Solution expected to add code/behavior + preserve backward-compat (pg compat issues are exception) T-sql-foundations SQL Foundations Team (formerly SQL Schema + SQL Sessions)

Comments

@rafiss
Copy link
Collaborator

rafiss commented Mar 29, 2022

The way the internal executor works is that when it manages the txn lifecycle (i.e. you pass it nil), then it runs the whole transaction state machine.

However, when you pass in a txn, then it moves itself to the open state with totally bogus extraTxnState and then when the statement finishes, it throws that bogus extraTxnState away.

This can lead to problems, since it bypasses the lifecycle and state management which normally happens for SQL transactions. For example: the deferred creation of jobs and the checking of the two version invariant.

See #76764 for an example where this caused real corruption.

Jira issue: CRDB-14493

Epic CRDB-14492

@rafiss rafiss added C-enhancement Solution expected to add code/behavior + preserve backward-compat (pg compat issues are exception) A-sql-executor SQL txn logic labels Mar 29, 2022
@blathers-crl blathers-crl bot added the T-sql-foundations SQL Foundations Team (formerly SQL Schema + SQL Sessions) label Mar 29, 2022
@ajwerner
Copy link
Contributor

cross-referencing for future discoverability: #69495 #71467

@rafiss
Copy link
Collaborator Author

rafiss commented Mar 29, 2022

cross-referencing for future discoverability

+1. I'm also putting all these in the same jira epic

@ajwerner
Copy link
Contributor

We should probably make the internal executor return an error if you feed it more than one statement in a batch. It has odd semantics both with and without a txn. We should also probably reject statements which perform any schema changes when providing a transaction explicitly, as we know that's not handled correctly.

@RichardJCai
Copy link
Contributor

We should probably make the internal executor return an error if you feed it more than one statement in a batch. It has odd semantics both with and without a txn. We should also probably reject statements which perform any schema changes when providing a transaction explicitly, as we know that's not handled correctly.

It actually does error right now now since we call ParseOne

@ajwerner
Copy link
Contributor

Okay, cool. One thing we could do is return an error for any schema change statement or non-DML that has a transaction provided by the call.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-sql-executor SQL txn logic C-enhancement Solution expected to add code/behavior + preserve backward-compat (pg compat issues are exception) T-sql-foundations SQL Foundations Team (formerly SQL Schema + SQL Sessions)
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants