Skip to content

FIX: Avoid unsupported isolation reset when closing pooled Synapse connections - #889

Merged
Jahnvi Thakkar (jahnvi480) merged 5 commits into
mainfrom
jahnvi/synapse-close-regression-16f
Nov 12, 2026
Merged

Jahnvi Thakkar (jahnvi480) merged 5 commits into
mainfrom
jahnvi/synapse-close-regression-16f

Conversation

@jahnvi480

@jahnvi480 Jahnvi Thakkar (jahnvi480) commented Nov 11, 2026 •

Copy link
Copy Markdown
Contributor

Work Item / Issue Reference

AB#50166

GitHub Issue: 882


Summary

Remove the redundant READ COMMITTED statement from the autocommit-on pool-return rollback batch. Azure Synapse dedicated SQL pools reject this statement, causing the 1.17.0 Connection.close() regression.

Preserve rollback, deferred session reset, cleanup-error propagation and pool-capacity recovery. Checkout isolation restoration and its existing discard/reconnect fallback remain unchanged. No engine-detection queries, new connection state or public API changes are introduced.

Add focused native coverage that rejects READ COMMITTED in the close batch and a pooled autocommit close-after-query integration case.

Validation

  • cmake --build mssql_python\pybind\build\x64\py313 --config Release --parallel 4 -- /verbosity:quiet /nologo - passed; Windows x64 Release extension and native test executable built.
  • ctest --test-dir mssql_python\pybind\build\x64\py313 -C Release --output-on-failure - passed.
  • .venv\Scripts\python.exe -m pytest -q tests\test_003_connection.py tests\test_006_exceptions.py tests\test_009_pooling.py -k 'close or isolation or explicit or noexec or positive_login or sanitation or generation or autocommit or attrs_before' --tb=short - 43 passed, 6 skipped, 294 deselected against the available SQL Server.
  • .venv\Scripts\python.exe -m pre_commit run black-check --all-files --hook-stage pre-push - passed.

Live Synapse dedicated-pool verification and the full test suite were not run.

Remove the redundant close-time READ COMMITTED statement while preserving rollback, session reset and existing checkout behavior. Add focused native and integration regression coverage.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot AI balanced review requested due to automatic review settings November 11, 2026 07:09
@github-actions github-actions Bot added the pr-size: small Minimal code update label Nov 11, 2026
@github-actions

github-actions Bot commented Nov 11, 2026 •

Copy link
Copy Markdown

PR Performance Report

✅ No regression detected

No consistent slowdowns detected across all 2 environments.

0 IMPROVEMENTS 0 SLOWDOWNS 2/2 ENVIRONMENTS

Coverage: 2 of 2 environments completed. Advisory result; does not block merging.

Performance diagnostics

Phase times are inclusive diagnostics and must not be added together. They identify where measured time changed, not why it changed.

No affected phases or call-count changes were recorded.

All database tasks and timings

Unix / SQL Server 2022

Database task Before After Paired change Result
Connection opening 10.342 ms 10.255 ms -2.2% no signal
SELECT queries 1.015 ms 1.017 ms +0.4% no signal
Row insertion 30.369 ms 30.598 ms +0.3% no signal
Executemany inserts 160.326 ms 160.340 ms -0.7% no signal
Fetch-all queries 120.697 ms 120.642 ms -0.2% no signal
Row-by-row fetching 4.981 ms 4.980 ms +0.2% no signal
Batched row fetching 116.005 ms 117.353 ms +0.6% no signal
Transaction commit and rollback 105.613 ms 104.661 ms -0.7% no signal
Arrow row fetching 90.932 ms 90.649 ms -0.2% no signal
100,000-row insertion 367.235 ms 345.152 ms -4.4% no signal
Row fetching in batches of 100 121.556 ms 120.295 ms -0.1% no signal
Row fetching in batches of 10,000 142.582 ms 127.099 ms -3.5% no signal
Repeated positional queries 31.863 ms 31.746 ms -0.4% no signal
Repeated named-parameter queries 32.164 ms 31.876 ms +0.1% no signal
Legacy 100,000-row insertion 255.226 ms 271.290 ms +6.3% no signal
Insertion with explicit input sizes 399.670 ms 381.885 ms -4.4% no signal
Joined aggregation queries 183.812 ms 181.659 ms +0.2% no signal
Large joined-result fetching 193.433 ms 188.114 ms -0.0% no signal
1.2-million-row fetching 3518.039 ms 3541.579 ms +0.5% no signal
Common table expression queries 5.440 ms 5.410 ms +0.3% no signal
256 KiB VARCHAR(MAX) / fetchall() 1.566 ms 1.285 ms -5.3% no signal
10,000 scalar values / fetchval() (debug disabled) 17.292 ms 17.355 ms -0.8% no signal
10,000 output-converted rows / fetchall() 19.771 ms 19.804 ms +3.6% no signal
10,000 output-converted rows / fetchmany(1000) 24.369 ms 24.006 ms -1.7% no signal
10,000 rows x 32 columns / dict(row._mapping) (warm) 34.032 ms 33.060 ms -2.8% no signal

Unix / SQL Server 2025

Database task Before After Paired change Result
Connection opening 97.611 ms 97.491 ms -0.6% no signal
SELECT queries 0.992 ms 1.001 ms +0.9% no signal
Row insertion 30.175 ms 30.220 ms +0.3% no signal
Executemany inserts 169.286 ms 161.425 ms -2.5% no signal
Fetch-all queries 123.277 ms 125.073 ms +1.5% no signal
Row-by-row fetching 5.207 ms 5.026 ms -2.5% no signal
Batched row fetching 117.385 ms 117.564 ms +0.4% no signal
Transaction commit and rollback 105.686 ms 105.035 ms -0.5% no signal
Arrow row fetching 91.187 ms 89.505 ms -2.6% no signal
100,000-row insertion 343.816 ms 345.682 ms +0.9% no signal
Row fetching in batches of 100 126.007 ms 125.558 ms +2.7% no signal
Row fetching in batches of 10,000 144.629 ms 143.855 ms +2.7% no signal
Repeated positional queries 31.181 ms 31.134 ms +0.3% no signal
Repeated named-parameter queries 31.762 ms 32.537 ms +1.2% no signal
Legacy 100,000-row insertion 257.710 ms 256.412 ms -0.4% no signal
Insertion with explicit input sizes 386.198 ms 384.082 ms -0.3% no signal
Joined aggregation queries 168.689 ms 167.971 ms -0.8% no signal
Large joined-result fetching 188.946 ms 201.841 ms +4.6% no signal
1.2-million-row fetching 3497.441 ms 3523.890 ms +0.9% no signal
Common table expression queries 5.098 ms 5.067 ms -0.2% no signal
256 KiB VARCHAR(MAX) / fetchall() 1.999 ms 1.975 ms -4.0% no signal
10,000 scalar values / fetchval() (debug disabled) 17.084 ms 17.652 ms -0.5% no signal
10,000 output-converted rows / fetchall() 19.649 ms 20.508 ms +4.4% no signal
10,000 output-converted rows / fetchmany(1000) 23.008 ms 23.239 ms +1.6% no signal
10,000 rows x 32 columns / dict(row._mapping) (warm) 32.423 ms 31.858 ms -1.0% no signal
Build and measurement details

ADO build 191414

PR head: f8be4aeb7ae1fa162b4808f68e67a5329b60bb48
Base: 444ae8c764272e55ded42c5f5a81bf35e8dbb327
Measured merge: 672ac63ca604cf6144df3cd9ffc290aeac2aabd1

  • Unix / SQL Server 2022: Python 3.12.3, x86_64, SQL 16.0.4315.2; 5 paired comparisons and 1 warmup.
  • Unix / SQL Server 2025: Python 3.12.3, x86_64, SQL 17.0.5045.3; 5 paired comparisons and 1 warmup.

A consistent change requires more than 20% median paired movement, at least 1 ms between the median runtimes, and at least 80% of pairs exceeding the relative threshold in the same direction. A slowdown without enough pair agreement is reported as inconsistent.

The displayed change is the median of paired before-and-after ratios. It is not recalculated from the two displayed median runtimes.

Both revisions use profiling-enabled builds on the same agent and database, with alternating order and discarded warmups. Results are diagnostic and do not represent production-wheel latency.

Raw samples and logs are attached to the ADO run as profiler-* artifacts.

@jahnvi480 Jahnvi Thakkar (jahnvi480) changed the title FIX: Avoid unsupported isolation reset when closing pooled Synapse connections (#882) FIX: Avoid unsupported isolation reset when closing pooled Synapse connections Nov 11, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Changes recommended

The test uses unsupported std::char_traits with unixODBC headers, preventing pool_sanitation_tests from compiling on libc++ 19+ configurations.

1 open issue
What changed in this PR

This PR addresses the pooled-connection close regression affecting Azure Synapse dedicated SQL pools by removing an unsupported isolation-level reset from the close-time rollback batch.

Changes:

  • Removes the redundant READ COMMITTED statement while preserving rollback and checkout-time isolation restoration.
  • Clarifies the session-reset state comment without changing its behavior.
  • Adds native regression coverage and a subprocess-isolated pooled autocommit close-after-query test.
File Description
tests/​test_009_pooling.py Adds repeated pooled autocommit query-and-close coverage.
tests/​native/​pool_sanitation.cpp Adds a mock rejection of READ COMMITTED and a close-time regression test.
mssql_python/​pybind/​connection/​connection.h Clarifies that checkout remains responsible for restoring isolation.
mssql_python/​pybind/​connection/​connection.cpp Removes the isolation reset from the pool-return rollback batch.

Review effort: Balanced

Comment thread tests/native/pool_sanitation.cpp Resolved
@github-actions

github-actions Bot commented Nov 11, 2026 •

Copy link
Copy Markdown

📊 Code Coverage Report

🔥 Diff Coverage

100%


🎯 Overall Coverage

85%


📈 Total Lines Covered: 11716 out of 13687
📁 Project: mssql-python


Diff Coverage

Diff: main...HEAD, staged and unstaged changes

  • mssql_python/pybind/connection/connection.cpp (100%)

Summary

  • Total: 3 lines
  • Missing: 0 lines
  • Coverage: 100%

📋 Files Needing Attention

📉 Files with overall lowest coverage (click to expand)
mssql_python.pybind.performance_counter.hpp: 0.7%
mssql_python.pybind.logger_bridge.cpp: 57.9%
mssql_python.pybind.ddbc_bindings.h: 65.5%
mssql_python.pybind.logger_bridge.hpp: 70.8%
mssql_python._native_fetch.py: 77.4%
mssql_python.pybind.ddbc_bindings.cpp: 80.5%
mssql_python.pybind.connection.connection_pool.cpp: 81.3%
mssql_python.pybind.row_mapping_cache.hpp: 81.5%
mssql_python.pybind.connection.connection.cpp: 82.5%
mssql_python.logging.py: 86.2%

🔗 Quick Links

⚙️ Build Summary 📋 Coverage Details

View Azure DevOps Build

Browse Full Coverage Report

@sumitmsft

Copy link
Copy Markdown
Contributor

Reviewed revision 0ee66c43a10f7a84b634c8eda8932fdba5336ea2.

The production change removes the unsupported close-time isolation statement while preserving rollback, deferred session reset, cleanup-error propagation, pool-capacity recovery, and checkout isolation restoration with discard/reconnect fallback. No additional production defects were identified by source inspection.

Recommendation: Request changes for the existing unresolved native-test portability issue at tests/native/pool_sanitation.cpp:162, already reported in #889 (comment). With unixODBC, SQLWCHAR is unsigned short; libc++ 19+ no longer provides generic std::char_traits, so the added length call prevents the optional native sanitation test target from compiling on those configurations. Count null-terminated SQLWCHAR elements directly before conversion. This does not imply a production-wheel build failure.

Evidence: https://releases.llvm.org/19.1.0/projects/libcxx/docs/ReleaseNotes.html#deprecations-and-removals

No local compilation or database execution was performed during this review. Live Synapse verification remains outstanding, as disclosed in the PR.

Count null-terminated SQLWCHAR elements directly instead of depending on the generic std::char_traits template removed in libc++ 19.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot AI balanced review requested due to automatic review settings November 11, 2026 08:03

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🔵 Needs a closer look

Live Synapse dedicated-pool validation remains outstanding, and SQL Server tests and native mocks do not establish deferred-reset and checkout-fallback behavior on the affected engine.

No open issues 🎉

1 resolved since last review

Review effort: Balanced

Copilot AI balanced review requested due to automatic review settings November 11, 2026 08:30

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🔵 Needs a closer look

Live Synapse dedicated-pool validation remains outstanding, and SQL Server and mocked ODBC checks do not verify the affected engine’s rollback-only reset and repeated pooled close/reconnect behavior.

No open issues 🎉

Review effort: Balanced

Copilot AI balanced review requested due to automatic review settings November 12, 2026 06:32

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🔵 Needs a closer look

Live Azure Synapse dedicated-pool validation of close-after-query and subsequent checkout/reconnect behavior remains outstanding; reported checks cover only SQL Server and a limited native mock.

No open issues 🎉

Review effort: Balanced

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Reviewed the PR for correctness, security, reliability, performance, test coverage, repository conventions, and applicable architecture and design specifications. No actionable issues were identified. The implementation is consistent with repository standards and the applicable approved design requirements.

Recommendation: Approve

Copilot AI balanced review requested due to automatic review settings November 12, 2026 08:06

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🔵 Needs a closer look

Validation covers only SQL Server and a native mock, leaving close-after-query, deferred session reset, and checkout discard/reconnect behavior unverified on the affected Synapse dedicated pool.

No open issues 🎉

Review effort: Balanced

@jahnvi480

Copy link
Copy Markdown
Contributor Author

/azp run

@azure-pipelines

Copy link
Copy Markdown
Contributor
Azure Pipelines:
Successfully started running 1 pipeline(s).

@jahnvi480
Jahnvi Thakkar (jahnvi480) merged commit bd83897 into main Nov 12, 2026
38 of 39 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pr-size: small Minimal code update

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants