Skip to content

Stage 4: auth/recovery, ODBC tests, mssql-python e2e (ADO #47340) - #302

Draft
Saurabh Singh (saurabh500) wants to merge 2 commits into
saurabh500-stage-3-reset-acking-isolationfrom
saurabh500-stage-4-auth-odbc-tests-python-e2e
Draft

Stage 4: auth/recovery, ODBC tests, mssql-python e2e (ADO #47340)#302
Saurabh Singh (saurabh500) wants to merge 2 commits into
saurabh500-stage-3-reset-acking-isolationfrom
saurabh500-stage-4-auth-odbc-tests-python-e2e

Conversation

@saurabh500

@saurabh500 Saurabh Singh (saurabh500) commented Aug 15, 2026

Copy link
Copy Markdown
Contributor

Stage 4 (final) of the mssql-odbc connection-pooling effort (ADO User Story #47317). Implements auth/recovery hardening, fills remaining ODBC test gaps, adds a live C++ e2e for pool reuse, and documents the mssql-python end-to-end verification plan.

Stacked on Stage 3 PR #301 (=> #296 => #294 => #293). Base branch: saurabh500-stage-3-reset-acking-isolation (NOT main).

Work item: AB#47340.

B6 — Auth / recovery context across reset (CONFIRMATION, no behavior change)

Traced the connect + reset paths. SQLSetConnectAttr(SQL_ATTR_RESET_CONNECTION) and TdsClient::reset_connection() are the same physical login: no LOGIN7/fedauth re-run, no token re-send, and on_reset_connection_ack() / restore_login_defaults() never touch recovery_context.client_context (auth state). A new/rotated access token only enters at connect time; setting SQL_COPT_SS_ACCESS_TOKEN after connect is rejected (HY011), so a rotated token forces a new physical login, never a live-session re-auth. This was a confirmation — the only changes are a doc comment on TdsClient::reset_connection and a lock-in unit test (access_token_after_connect_is_rejected).

B7 — ODBC tests

  • Unit gap filled: connection_dead_reports_true_when_client_marked_dead (a connected-but-poisoned client reads SQL_CD_TRUE). Existing coverage already had connected/disconnected/never-connected, value validation, busy rejection, poison-on-failure, and isolation re-apply.
  • Live C++ e2e: mssql-odbc/tests/e2e/tests/connection_pool_test.cpp, mirroring transaction_test.cpp structure and gating (HasConnection()), registered in CMakeLists. Borrower A mutates isolation/temp-table/txn/database; the pool checks in + resets; borrower B on the same @spid sees clean login defaults (no temp table, @@TRANCOUNT=0, isolation back to READ COMMITTED, original DB), plus prepared-statement survival, per-checkout isolation reset, and CONNECTION_DEAD staying FALSE on a healthy connection.

Workstream C — mssql-python e2e

No in-repo mssql-python/Python-pool harness exists, and adding one would pull heavy Python + mssql-python infra into mssql-rs (against the "no second pool" non-goal). Per the plan's guidance, added a concise verification plan docs/odbc-connection-pooling-python-e2e.md covering scenarios (a)–(f) — same-connection reuse, dead-connection discard, prepared-statement invalidation, concurrent checkout, token-identity separation + near-expiry reconnect, and the #343 isolation-reset — using the existing driver-registration hook (run_e2e.ps1/.sh). Linked from the main plan doc.

Definition of Done status

# Criterion Status
1 mssql-python reuses a physical Rust connection, no second Rust pool Code (primitives) + documented e2e (WS-C)
2 SQL_ATTR_CONNECTION_DEAD cached, no probe Code (Stage 2) + unit incl. new known-dead test
3 SQL_ATTR_RESET_CONNECTION arms real reset; clean fail when disconnected/busy Code (Stage 2/3) + unit
4 Reset acked before checkout; borrower B sees no leaked temp/txn/db/isolation Code (Stage 3) + new live C++ e2e
5 SQL_ATTR_TXN_ISOLATION real server change incl. reset to READ COMMITTED Code (Stage 3) + unit + e2e
6 Autocommit set/get + commit/rollback lifecycle Code (prior) + unit
7 Reset ack invalidates prepared handles + client metadata Code (Stage 1) + TDS unit + e2e re-prepare
8 No DBC mutex across I/O; busy never mistaken for dead/idle Code (Stage 2/3) + unit
9 Unit, live-server, mssql-python e2e pass Unit green; live C++ e2e added (gated); WS-C documented-for-CI
10 cargo bfmt, cargo bclippy, focused suites pass Green (see below)

Validation

  • cargo bfmtcargo bclippy ✅ (warnings-as-errors)
  • mssql-odbc lib nextest: 578 passed. Targeted pooling/reset/auth unit tests: pass. TDS reset-ack unit tests: pass.
  • The C++ e2e and the pre-existing mssql-tds live reset tests require a live SQL Server (SQL_PASSWORD/server), unavailable in this environment — they are gated and left for live/CI. No new failures introduced.

Non-goals kept intact

No second Rust pool; no live-session token refresh; no raw-T-SQL isolation reset (shared, documented limitation matching msodbcsql/mssql-python #343).

…2e plan

Confirm SQLSetConnectAttr(SQL_ATTR_RESET_CONNECTION) and
TdsClient::reset_connection() preserve the auth/recovery context (same
physical login, no re-auth), documented on reset_connection and locked in
by a test rejecting a post-connect access token (B6).

Fill remaining ODBC unit gaps: CONNECTION_DEAD reports dead for a
client marked known-dead. Add a live C++ e2e (connection_pool_test.cpp)
mirroring transaction_test.cpp: same-physical-connection reuse, clean
state for the next borrower, isolation reset each checkout, prepared
statement survival, and value validation.

Document the mssql-python end-to-end verification plan
(odbc-connection-pooling-python-e2e.md) since no in-repo Python pool
harness exists; reference it from the main plan.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 63e24621-7665-4572-a5b8-e5dfa55060a0
The reprepare-after-reset test asserts mssql-odbc-specific behavior: our
driver transparently re-prepares after sp_reset_connection drops the
server-side handle, while msodbcsql blindly reuses the dropped handle and
fails (native 8179). Add SKIP_IF_COMPARING_MSODBCSQL() so the parity
comparison leg skips this intended divergence, mirroring transaction_test.cpp.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 63e24621-7665-4572-a5b8-e5dfa55060a0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:connectionpool Work done for connection pool enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant