Skip to content

Allow a caller-provided retry schedule for PostgreSQL connection checkout - #10792

Merged
tim-smart merged 7 commits into
Effect-TS:v4/next-minorfrom
brandon-julio-t:feat/sql-pg-connect-retry-schedule
Nov 20, 2026
Merged

tim-smart merged 7 commits into
Effect-TS:v4/next-minorfrom
brandon-julio-t:feat/sql-pg-connect-retry-schedule

Conversation

@brandon-julio-t

@brandon-julio-t brandon-julio-t commented Nov 20, 2026 •

Copy link
Copy Markdown
Contributor

Add an optional connectRetrySchedule to PgClient.PgPoolConfig and PgPool.Config so callers can opt into retrying retryable connection errors (error.isRetryable, such as socket errors, connectTimeout, and SQLSTATE class 08) while opening a pooled connection on checkout. Authentication failures are not retried, and omitting the schedule preserves the existing behavior.

  • Retries run on the caller's fiber at checkout (wrapping both get and reserve), so interrupting the caller cancels pending retries and acquireTimeout bounds the entire checkout including backoff delays.
  • Statements and transaction bodies are never replayed; a lost reply after a statement is sent still fails the caller once.
  • When connectRetrySchedule is set, PgPool.use falls back to Effect.scoped(Effect.flatMap(get, f)) so acquisition retries do not wrap f.

Tests

One test in packages/sql/pg/test/PgPool.in-process.test.ts under PgPool failed startup: the first connect drops its socket and is retried, the second fails authentication (28P01) and is not retried, so checkout fails with AuthenticationError after two attempts. It fails if the retry is removed or if the isRetryable gate is removed.

Closes #10789
Closes EFF-4051
Closes EFF-4049

A stalled handshake can fail an ordinary query before a statement reaches the server. Let callers opt into a schedule at checkout, where a retry cannot repeat a statement, transaction or notification. Keep the pool acquisition deadline and the existing default.

Verified 31 PgPool and PgConnection cases, including backoff, interruption during the delay, and a disconnect after a write. Lint and type checks pass on the tested upstream base.

gpt-6.2-astra - high
@changeset-bot

changeset-bot Bot commented Nov 20, 2026 •

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 75f7441

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

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

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-bot
effect-bot changed the base branch from main to v4/next-minor November 20, 2026 03:08
@github-actions

github-actions Bot commented Nov 20, 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 40.19 KB 40.19 KB 0.00 KB (0.00%)
basic.ts 7.35 KB 7.35 KB 0.00 KB (0.00%)
batching.ts 11.31 KB 11.31 KB 0.00 KB (0.00%)
brand.ts 7.00 KB 7.00 KB 0.00 KB (0.00%)
cache.ts 11.83 KB 11.83 KB 0.00 KB (0.00%)
config.ts 23.23 KB 23.23 KB 0.00 KB (0.00%)
differ.ts 22.34 KB 22.34 KB 0.00 KB (0.00%)
http-client.ts 27.76 KB 27.76 KB 0.00 KB (0.00%)
http-router.ts 37.87 KB 37.87 KB 0.00 KB (0.00%)
logger.ts 12.29 KB 12.29 KB 0.00 KB (0.00%)
metric.ts 9.74 KB 9.74 KB 0.00 KB (0.00%)
optic.ts 7.24 KB 7.24 KB 0.00 KB (0.00%)
pubsub.ts 16.34 KB 16.34 KB 0.00 KB (0.00%)
queue.ts 13.23 KB 13.23 KB 0.00 KB (0.00%)
schedule.ts 12.08 KB 12.08 KB 0.00 KB (0.00%)
schema-bigdecimal.ts 14.35 KB 14.35 KB 0.00 KB (0.00%)
schema-binary.ts 42.82 KB 42.82 KB 0.00 KB (0.00%)
schema-class.ts 22.07 KB 22.07 KB 0.00 KB (0.00%)
schema-codegen.ts 30.83 KB 30.83 KB 0.00 KB (0.00%)
schema-fromJsonSchemaDocument.ts 30.69 KB 30.69 KB 0.00 KB (0.00%)
schema-representation-roundtrip.ts 28.38 KB 28.38 KB 0.00 KB (0.00%)
schema-string-transformation.ts 15.67 KB 15.67 KB 0.00 KB (0.00%)
schema-string.ts 12.55 KB 12.55 KB 0.00 KB (0.00%)
schema-template-literal.ts 16.53 KB 16.53 KB 0.00 KB (0.00%)
schema-toArbitrary.ts 39.76 KB 39.76 KB 0.00 KB (0.00%)
schema-toCodecJson.ts 21.25 KB 21.25 KB 0.00 KB (0.00%)
schema-toEquivalence.ts 21.41 KB 21.41 KB 0.00 KB (0.00%)
schema-toFormatter.ts 21.50 KB 21.50 KB 0.00 KB (0.00%)
schema-toJsonSchemaDocument.ts 26.55 KB 26.55 KB 0.00 KB (0.00%)
schema-toRepresentation.ts 21.59 KB 21.59 KB 0.00 KB (0.00%)
schema.ts 21.18 KB 21.18 KB 0.00 KB (0.00%)
stm.ts 14.56 KB 14.56 KB 0.00 KB (0.00%)
stream.ts 10.68 KB 10.68 KB 0.00 KB (0.00%)
supervisor.ts 11.61 KB 11.61 KB 0.00 KB (0.00%)

@effect-bot
effect-bot force-pushed the v4/next-minor branch 8 times, most recently from a6604a9 to cf6cce5 Compare November 20, 2026 03:56
@tim-smart
tim-smart enabled auto-merge (squash) November 20, 2026 07:54
@tim-smart
tim-smart merged commit 0574431 into Effect-TS:v4/next-minor Nov 20, 2026
15 checks passed
@brandon-julio-t
brandon-julio-t deleted the feat/sql-pg-connect-retry-schedule branch November 20, 2026 08:08
effect-bot added a commit that referenced this pull request Nov 22, 2026
effect-bot added a commit that referenced this pull request Nov 22, 2026
effect-bot added a commit that referenced this pull request Nov 23, 2026
effect-bot added a commit that referenced this pull request Nov 23, 2026
effect-bot added a commit that referenced this pull request Nov 23, 2026
effect-bot added a commit that referenced this pull request Nov 23, 2026
effect-bot added a commit that referenced this pull request Nov 23, 2026
effect-bot added a commit that referenced this pull request Nov 23, 2026
effect-bot added a commit that referenced this pull request Nov 23, 2026
effect-bot added a commit that referenced this pull request Nov 23, 2026
effect-bot added a commit that referenced this pull request Nov 23, 2026
effect-bot added a commit that referenced this pull request Nov 23, 2026
effect-bot added a commit that referenced this pull request Nov 23, 2026
effect-bot added a commit that referenced this pull request Nov 23, 2026
effect-bot added a commit that referenced this pull request Nov 23, 2026
effect-bot added a commit that referenced this pull request Nov 23, 2026
effect-bot added a commit that referenced this pull request Nov 23, 2026
effect-bot added a commit that referenced this pull request Nov 23, 2026
effect-bot added a commit that referenced this pull request Nov 23, 2026
effect-bot added a commit that referenced this pull request Nov 23, 2026
effect-bot added a commit that referenced this pull request Nov 23, 2026
effect-bot added a commit that referenced this pull request Nov 24, 2026
effect-bot added a commit that referenced this pull request Nov 24, 2026
effect-bot added a commit that referenced this pull request Nov 24, 2026
effect-bot added a commit that referenced this pull request Nov 24, 2026
effect-bot added a commit that referenced this pull request Nov 24, 2026
effect-bot added a commit that referenced this pull request Nov 25, 2026
effect-bot added a commit that referenced this pull request Nov 25, 2026
effect-bot added a commit that referenced this pull request Nov 25, 2026
effect-bot added a commit that referenced this pull request Nov 25, 2026
effect-bot added a commit that referenced this pull request Nov 25, 2026
effect-bot added a commit that referenced this pull request Nov 25, 2026
effect-bot added a commit that referenced this pull request Nov 25, 2026
effect-bot added a commit that referenced this pull request Nov 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

sql-pg: allow caller-controlled retries when acquiring a connection before SQL is sent

3 participants