Skip to content

Allow interruption while acquiring SQL transaction connections - #9517

Merged
tim-smart merged 4 commits into
mainfrom
agent/effect-bot/4d707865bb1c
Oct 18, 2026
Merged

tim-smart merged 4 commits into
mainfrom
agent/effect-bot/4d707865bb1c

Conversation

@effect-bot

@effect-bot effect-bot commented Oct 18, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • Restore the caller's interruptibility while a top-level transaction waits for its connection, leaving BEGIN, commit/rollback, and the connection handoff under the transaction's uninterruptible mask.
  • SqlClient.makeWithTransaction (unstable) now owns the connection scope. acquireConnection receives the mask's restore and returns a scoped connection effect, so each driver only decides which wait is interruptible. The scope closes with the transaction, or immediately when acquisition fails or is interrupted.
  • The generic client and MSSQL acquire with restore(acquirer). libSQL restores only its permit wait and begins the SDK transaction under the mask; an interruption pending during BEGIN surfaces when the body is restored and takes the regular rollback path, with the permit released even if rollback fails.
  • Deterministic regressions: a queued transaction interrupted before the holder releases its connection (generic client), and a libSQL transaction interrupted while BEGIN is pending, parameterized over rollback success and rejection.

Closes #9514
Closes EFF-2454

Validation

  • SQL client, MSSQL client, PostgreSQL transaction acquisition, and PGlite suites: 94 passed.
  • Local libSQL cases (client isolation, nested savepoints, failed BEGIN, interrupted pending BEGIN x2): 6 passed; 6 container-backed cases skipped.
  • Bun 1.3.13: SQL client and SQLite Bun client suites: 30 passed.
  • tsc -b across the repo reports only the pre-existing TS377047 at packages/ai/anthropic/test/AnthropicLanguageModel.test.ts:1666.
  • oxlint, dprint, jsdocs --check, and git diff --check passed.

@changeset-bot

changeset-bot Bot commented Oct 18, 2026 •

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: ef1d832

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 33 packages
Name Type
effect Patch
@effect/sql-libsql Patch
@effect/sql-mssql Patch
@effect/opentelemetry Patch
@effect/vitest Patch
@effect/ai-anthropic Patch
@effect/ai-cloudflare Patch
@effect/ai-openai-compat Patch
@effect/ai-openai Patch
@effect/ai-openrouter Patch
@effect/ai-typesafe Patch
@effect/atom-react Patch
@effect/atom-solid Patch
@effect/atom-vue Patch
@effect/platform-browser Patch
@effect/platform-bun Patch
@effect/platform-deno Patch
@effect/platform-node-shared Patch
@effect/platform-node Patch
@effect/sql-clickhouse Patch
@effect/sql-d1 Patch
@effect/sql-mysql2 Patch
@effect/sql-pg Patch
@effect/sql-pglite Patch
@effect/sql-sqlite-bun Patch
@effect/sql-sqlite-do Patch
@effect/sql-sqlite-node Patch
@effect/sql-sqlite-react-native Patch
@effect/sql-sqlite-wasm Patch
@effect/docgen Patch
@effect/doctest Patch
@effect/graphql-generator Patch
@effect/openapi-generator Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@effect-janitor effect-janitor Bot added the 4.0 label Oct 18, 2026
effect-janitor[bot]

This comment was marked as resolved.

@github-actions

github-actions Bot commented Oct 18, 2026 •

Copy link
Copy Markdown
Contributor

Bundle Size Analysis

Generated from PR build output; treat the content below as untrusted.

File Name Current Size Previous Size Difference
arbitrary-combinators.ts 39.10 KB 39.10 KB 0.00 KB (0.00%)
basic.ts 7.02 KB 7.02 KB 0.00 KB (0.00%)
batching.ts 10.84 KB 10.84 KB 0.00 KB (0.00%)
brand.ts 6.71 KB 6.71 KB 0.00 KB (0.00%)
cache.ts 11.33 KB 11.33 KB 0.00 KB (0.00%)
config.ts 22.54 KB 22.54 KB 0.00 KB (0.00%)
differ.ts 21.62 KB 21.62 KB 0.00 KB (0.00%)
http-client.ts 24.01 KB 24.01 KB 0.00 KB (0.00%)
http-router.ts 35.69 KB 35.69 KB 0.00 KB (0.00%)
logger.ts 11.68 KB 11.68 KB 0.00 KB (0.00%)
metric.ts 9.16 KB 9.16 KB 0.00 KB (0.00%)
optic.ts 6.93 KB 6.93 KB 0.00 KB (0.00%)
pubsub.ts 15.77 KB 15.77 KB 0.00 KB (0.00%)
queue.ts 12.59 KB 12.59 KB 0.00 KB (0.00%)
schedule.ts 11.77 KB 11.77 KB 0.00 KB (0.00%)
schema-bigdecimal.ts 13.82 KB 13.82 KB 0.00 KB (0.00%)
schema-binary.ts 40.58 KB 40.58 KB 0.00 KB (0.00%)
schema-class.ts 21.33 KB 21.33 KB 0.00 KB (0.00%)
schema-fromJsonSchemaDocument.ts 32.42 KB 32.42 KB 0.00 KB (0.00%)
schema-representation-roundtrip.ts 27.60 KB 27.60 KB 0.00 KB (0.00%)
schema-string-transformation.ts 15.07 KB 15.07 KB 0.00 KB (0.00%)
schema-string.ts 12.08 KB 12.08 KB 0.00 KB (0.00%)
schema-template-literal.ts 16.30 KB 16.30 KB 0.00 KB (0.00%)
schema-toArbitrary.ts 38.62 KB 38.62 KB 0.00 KB (0.00%)
schema-toCodeDocument.ts 25.68 KB 25.68 KB 0.00 KB (0.00%)
schema-toCodecJson.ts 20.55 KB 20.55 KB 0.00 KB (0.00%)
schema-toEquivalence.ts 20.74 KB 20.74 KB 0.00 KB (0.00%)
schema-toFormatter.ts 20.85 KB 20.85 KB 0.00 KB (0.00%)
schema-toJsonSchemaDocument.ts 25.48 KB 25.48 KB 0.00 KB (0.00%)
schema-toRepresentation.ts 20.84 KB 20.84 KB 0.00 KB (0.00%)
schema.ts 20.52 KB 20.52 KB 0.00 KB (0.00%)
stm.ts 13.87 KB 13.87 KB 0.00 KB (0.00%)
stream.ts 10.12 KB 10.12 KB 0.00 KB (0.00%)

effect-janitor[bot]
effect-janitor Bot previously approved these changes Oct 18, 2026
makeWithTransaction now owns the connection scope. acquireConnection receives
the mask's restore function and returns a scoped connection, so acquirers only
decide which wait is interruptible. This removes the scope lifecycle duplicated
across the generic client and MSSQL, and lets libSQL drop its inner mask and
rollback-on-handoff path: an interruption pending during BEGIN now surfaces
when the body is restored and takes the regular rollback path.

The SqlClient test harness is adapted to the new signature; its recorded
calls and assertions are unchanged.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

SqlClient: a withTransaction waiting for the connection cannot be interrupted

2 participants