Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
84d8c2c
PERF: Revert pooled connection cleanup from PR #777
sumitmsft Sep 25, 2026
489ba0d
PERF: Preserve pooled transaction safety with a proven-clean fast path
sumitmsft Sep 25, 2026
cf988f4
STYLE: Format pooling timeout regression assertion
sumitmsft Sep 25, 2026
e7444e7
PERF: Reduce pooled connection cleanup overhead
sumitmsft Sep 26, 2026
b759715
PERF: Avoid redundant pooled setters and empty diagnostic reads
sumitmsft Oct 7, 2026
ac1761a
TEST: Handle diagnostic count probes and gate native sanitation in CI
sumitmsft Oct 9, 2026
205b491
Merge branch 'main' into sumitmsft/revert-777-pooling-performance-202…
sumitmsft Oct 12, 2026
27e2259
TEST: Bounds-check native getInfo fixture without memcpy
sumitmsft Oct 12, 2026
07241b7
Merge branch 'main' into sumitmsft/revert-777-pooling-performance-202…
bewithgaurav Oct 12, 2026
52eb193
FIX: Discard pooled connections after failed child handle cleanup
sumitmsft Oct 12, 2026
e0fe2f1
Merge branch 'main' into sumitmsft/revert-777-pooling-performance-202…
jahnvi480 Oct 13, 2026
04e13fd
Merge branch 'main' into sumitmsft/revert-777-pooling-performance-202…
sumitmsft Oct 13, 2026
6fa455e
Merge branch 'main' into sumitmsft/revert-777-pooling-performance-202…
bewithgaurav Oct 26, 2026
3840ee7
CHORE: Merge main into pooling performance branch
bewithgaurav Nov 2, 2026
613b1e8
FIX: Preserve bounded pooled autocommit validation
bewithgaurav Nov 2, 2026
6fcc7fb
FIX: Keep bounded checkout probe on clean pooled leases
bewithgaurav Nov 2, 2026
c156bf6
FIX: Probe clean pooled leases under timeout
bewithgaurav Nov 2, 2026
73a0ebf
CHORE: Merge main after mssql-python-rs 0.4.0 update
bewithgaurav Nov 2, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,13 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
does not change the default provider or ship any Rust driver binaries.

### Changed
- Pooled check-in skips transaction sanitation only after a prior successful
native rollback/autocommit restore and no subsequent statement allocation or
uncertain operation. Used connections still roll back explicit transactions
before parking; sanitation uses one native attribute probe and one GIL release.
Raw-handle exposure and arbitrary connection attributes disable the fast path;
successfully applied scalar login timeouts (including `connect(timeout=30)`)
do not permanently disable it.
- Fetches reuse owned native metadata for stable columns within a result set;
`fetchmany()` avoids the Python metadata-dictionary roundtrip. Re-execution,
result transitions and statement/connection cleanup invalidate this metadata.
Expand Down
38 changes: 38 additions & 0 deletions eng/pipelines/pr-validation-pipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,44 @@ jobs:
targetPath: '$(Build.ArtifactStagingDirectory)/rs-runtime'
artifact: 'rs-runtime-selection'

- job: NativePoolSanitation
dependsOn: SelectRsRuntime
variables:
MSSQL_PYTHON_RS_VERSION: $[ dependencies.SelectRsRuntime.outputs['select.version'] ]
displayName: 'Native pool sanitation tests'
Comment thread
sumitmsft marked this conversation as resolved.
Resolved
timeoutInMinutes: 20
pool:
vmImage: 'ubuntu-latest'

steps:
- checkout: self
persistCredentials: false

- task: UsePythonVersion@0
inputs:
versionSpec: '3.13'
addToPath: true
displayName: 'Use Python 3.13 for native tests'

- bash: |
set -euo pipefail
sudo apt-get update
sudo apt-get install -y build-essential cmake unixodbc-dev
python -m pip install --no-deps --require-hashes -r eng/requirements-build-linux.txt
displayName: 'Install native test build dependencies'

- bash: |
set -euo pipefail
cmake -S mssql_python/pybind -B mssql_python/pybind/build/native-tests \
-DCMAKE_BUILD_TYPE=Release -DENABLE_PROFILING=OFF \
-DBUILD_NATIVE_POOL_TESTS=ON -DPython3_EXECUTABLE="$(command -v python)"
cmake --build mssql_python/pybind/build/native-tests \
--config Release --target pool_sanitation_tests --parallel 2
ctest --test-dir mssql_python/pybind/build/native-tests \
-C Release --output-on-failure --no-tests=error \
--timeout 120 -R '^pool_sanitation$'
displayName: 'Build and run native pool sanitation tests'

- job: CodeQLAnalysis
dependsOn: SelectRsRuntime
variables:
Expand Down
27 changes: 3 additions & 24 deletions mssql_python/connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -2232,35 +2232,14 @@ def close(self) -> None:
# Close the connection even if cursor cleanup had issues
try:
if self._conn:
autocommit_error = None
rollback_error = None
manual_commit = False
# Native close owns transaction cleanup and fail-closed discard.
# Avoid duplicate attribute probes and untrusted rollback hints.
try:
manual_commit = not self._conn.get_autocommit()
except RuntimeError as e:
autocommit_error = e
if manual_commit:
# End caller work before native close. Pooled connections are
# additionally restored to autocommit by native check-in,
# which atomically discards them if sanitation fails.
logger.debug("Rolling back uncommitted changes before closing connection.")
try:
self._conn.rollback()
except RuntimeError as e:
rollback_error = e
# TODO: Check potential race conditions in case of multithreaded scenarios
# Close the connection
try:
self._conn.close(manual_commit and rollback_error is None)
self._conn.close(rollback_before_disconnect=True)
except RuntimeError as e:
_raise_connection_error(e)
finally:
self._conn = None
if rollback_error is not None:
# Preserve prior DB-API error mapping after deterministic cleanup.
_raise_connection_error(rollback_error)
if autocommit_error is not None:
_raise_connection_error(autocommit_error)
except Exception as e:
logger.error(f"Error closing database connection: {e}")
# Re-raise the connection close error as it's more critical
Expand Down
18 changes: 18 additions & 0 deletions mssql_python/pybind/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -399,3 +399,21 @@ if(APPLE)
target_compile_definitions(ddbc_bindings PRIVATE MACOS_STRING_FIX)
target_compile_options(ddbc_bindings PRIVATE -DAPPLE_SILICON)
endif()

# Exercise the real connection/pool/handle code against deterministic ODBC
# function pointers, without shipping test hooks in the extension.
option(BUILD_NATIVE_POOL_TESTS "Build database-free native pool sanitation tests" OFF)
if(BUILD_NATIVE_POOL_TESTS)
Comment thread
sumitmsft marked this conversation as resolved.
Resolved
find_package(Python3 COMPONENTS Development REQUIRED)
get_target_property(pool_test_sources ddbc_bindings SOURCES)
add_executable(pool_sanitation_tests ${pool_test_sources}
../../tests/native/pool_sanitation.cpp)
foreach(property INCLUDE_DIRECTORIES COMPILE_DEFINITIONS COMPILE_OPTIONS)
set_property(TARGET pool_sanitation_tests PROPERTY ${property}
$<TARGET_PROPERTY:ddbc_bindings,${property}>)
endforeach()
target_link_libraries(pool_sanitation_tests PRIVATE
Python3::Python simdutf::simdutf ${CMAKE_DL_LIBS})
enable_testing()
add_test(NAME pool_sanitation COMMAND pool_sanitation_tests)
endif()
Loading
Loading