fix(mssql): avoid calling .commit()
unless a DDL operation is being performed
#9658
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR attempts to address flaky behavior of MS SQL observed in CI.
It seems like calling
commit()
/rollback()
with aSELECT
statement, AKA autocommit behaviorcan cause this issue.
The origin is not 100% clear to me, but there are a number of places where the
same problem (function sequence error) with the same solution show up
(disabling autocommit or not calling commit with a
SELECT
statement):Here I avoid calling
cur.commit()
unless a DDL statement is being executed.The remaining case is
raw_sql()
, which I opted to avoid callingcommit
insince that would have this problem when calling it with a
SELECT
statement.Users of
raw_sql
are therefore responsible for handling commit/rollback wheninvoking it for DDL statements.
Closes #9654.