Menu

Postgres cutover: four things a green replica does not tell you
📰

Postgres cutover: four things a green replica does not tell you

DEV Community: postgres·Hritik Chaudhary·3 days ago
#qeuRvccM
Long article (674 words) — no AI summary yet.
Reading 0:00
15s threshold

A Postgres cutover can go cleanly on the replica side and still break the application an hour later. The replica caught up, the promote worked, the health check is green. Four things that a green replica does not tell you are worth checking before you call it done.

1. Sequences do not come along with logical replication

Physical (streaming) replication copies everything, sequences included. Logical replication, which is what most major-version upgrades and low-downtime migrations use, copies row changes only. The sequence on the new primary stays where it was when the subscription was created.

The result shows up on the first insert after cutover: duplicate key value violates unique constraint , because nextval() hands out an id that already exists.

Check every serial or identity column before you open the writes:

SELECT schemaname , sequencename , last_value FROM pg_sequences ; SELECT max ( id ) FROM orders ;

Enter fullscreen mode

Exit fullscreen mode

If last_value is lower than max(id) , fix it…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.