Hold the shared PostgreSQL client permit through transactions - #6991
Conversation
🦋 Changeset detectedLatest commit: 59e12a5 The changes in this PR will be included in the next version bump. This PR includes changesets to release 30 packages
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 |
There was a problem hiding this comment.
ℹ️ No critical issues — the reproduction test is a focused regression spec and the described fix direction matches the patterns used by the other single-client adapters.
Reviewed changes
- Added
packages/sql/pg/test/Client.integration.test.ts:385-431, a deterministic regression test that verifies two concurrentwithTransactioncalls on a sharedpg.Clientcannot interleaveBEGINstatements.
@v0 or keep the SHA fresh with Dependabot | Fix all ➔ | Fix 👍s ➔ | View workflow run | Using Kimi K2 (free via Pullfrog for OSS) | 𝕏
…ed9835f2 # Conflicts: # packages/sql/pg/test/Client.integration.test.ts
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
Reviewed the incremental delta since the prior Pullfrog review (4408ff7).
- Implemented the scoped transaction acquirer in
packages/sql/pg/src/PgClient.ts;transactionAcquirernow holds the sharedpg.Clientsemaphore for the full transaction scope and releases it in a scope finalizer, matching the existingPgliteClient/SqliteClientpattern. - Added the patch changeset
.changeset/eff-428-pg-transaction-permit.mdfor@effect/sql-pg. - Updated the regression test in
packages/sql/pg/test/Client.integration.test.tsto complete theDeferredsynchronously viaDeferred.doneUnsafeand to provide the requiredReactivity.layer.
@v0 or keep the SHA fresh with Dependabot | View workflow run | Using Kimi K2 (free via Pullfrog for OSS) | 𝕏
Bundle Size AnalysisGenerated from PR build output; treat the content below as untrusted.
|

Summary
pg.Clientsemaphore permit for the full transaction scope so concurrent transactions cannot interleaveBEGINstatements or transaction bodies.@effect/sql-pg.Audit finding
Module:
pg/PgClientAudit ID:
sql-adapters-pg-2Severity / confidence: high / high
PgClient.fromClientpreviously usedsemaphore.withPermit(Effect.succeed(connection))as its transaction acquirer. That released the permit immediately after returning the connection, beforeBEGINand the transaction body ran.The transaction acquirer now registers permit release on the transaction scope, matching the scoped single-client pattern used by the other SQL adapters.
Validation
Audit provenance
c9b56ab507f224426ee8388dc450da447ec4715fc9b56ab507f224426ee8388dc450da447ec4715fsql-adapters-pg-2Closes EFF-428