You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat(postgres-js): add OCC retry with exponential backoff (#495)
## Summary
Added automatic retry with exponential backoff + jitter for OCC
conflicts on begin() transactions, with constructor-level and per-call
configuration. Fixed region parsing to gracefully fall back to
`AWS_REGION` / `AWS_DEFAULT_REGION` env vars.
## Changes
- `src/occ-retry.ts` — retry module (resolveRetryConfig,
executeWithRetry, isOCCError, validateRetryConfig, calculateBackoff)
- `src/client.ts` — wrapBegin() patches sql.begin() for both TCP and
WebSocket clients; region parsing fix
- `src/index.ts` — export isOCCError, OCCRetryConfig, Logger types
- `test/occ-retry.test.ts` — unit tests for isOCCError,
resolveRetryConfig, validation
- `test/integration/dsql.integration.test.ts` — 3 OCC integration tests
- `README.md` — OCC Retry documentation section + config table entries
- `example/` — updated preferred and no-pool examples with retry usage
## Test plan
- [x] Unit tests pass (46 tests — 2 suites)
- [x] TypeScript compiles clean
- [x] Integration tests pass against DSQL cluster (33 tests —
constructor opt-in, per-call opt-in, non-OCC passthrough)
*Issue #, if available:*
N/A
By submitting this pull request, I confirm that you can use, modify,
copy, and redistribute this contribution, under the terms of your
choice.
Co-authored-by: Prabakaran Annadurai <prabaw@amazon.com>
**Note:** The callback may be invoked multiple times on OCC conflicts. Keep it idempotent - avoid non-database side effects (HTTP calls, message publishes, external counters) inside the transaction body.
0 commit comments