SIGN IN SIGN UP
payloadcms / payload UNCLAIMED

Payload is the open-source, fullstack Next.js framework, giving you instant backend superpowers. Get a full TypeScript backend and admin panel instantly. Use Payload as a headless CMS or for building powerful applications.

0 0 12 TypeScript

fix(db-postgres): stabilize read replicas support (#16083)

- Fixes https://github.com/payloadcms/payload/issues/13011 and
https://github.com/payloadcms/payload/issues/13588
- Adds `postgres-replicas` configuration to our `docker-compose.yml`.
- Enables CI tests with `postgres-read-replicas` database adapter
option.
- Adds dedicated test suite `test/database/pg-replica/int.spec.ts` for
the `readReplicas` property

### Problem
When readReplicas is configured, reads that happen as part of writes
(e.g. reading back the row after an INSERT) were incorrectly routed to
the replica instead of the primary, causing NotFound errors due to
replication lag.

### Solution 
- `getPrimaryDb` - used in `upsertRow`, updateOne, `updateMany` to
always use the primary DB for internal reads in write operations.
- `readReplicasAfterWriteInterval` - time-based read-after-write
consistency. Before, if you did for example `payload.create` and
immediately `payload.find` after - the new document would not show due
to replication lag. Defaults to `2000` (ms) but can be configured.



---
- To see the specific tasks where the Asana app for GitHub is being
used, see below:
  - https://app.asana.com/0/0/1213830896242727
S
Sasha committed
46ddf8daf0d6deaa9ab888a73d56e1b0e328fdfe
Parent: aa143e6
Committed by GitHub <noreply@github.com> on 3/30/2026, 5:45:24 PM