# README
Upgrade procedure
The operator does the upgrade using PostgreSQL's pg_upgrade --link mode. Usually this results in little downtime. The upgrade has the following stages:
- preupgrade
- preupgrade-sync
- scaledown
- primary-upgrade
- secondary-upgrade
- primary-upgrade-move
- postupgrade
Upgrade stages
Preupgrade
Database settings which are needed for initdb
are extracted from current running database.
Database is reachable in this stage.
Preupgrade-sync
Database is reconfigured to listen on different port (55432) to ensure no clients are connected. Then, the operator starts a job to monitor replicas that they are caught up with primary. It does this by issuing CHECKPOINT on primary, then waiting for wal to be replicated, then issuing CHECKPOINT in replicas. Then repeat this cycle until WAL position does not change on primary.
During this, database is not reachable.
Scaledown
Database is stopped in this phase.
Primary upgrade
Primary node is upgraded, and new database system id is returned. Upgraded database is in data.new
, which will be moved to its final location later.
Secondary upgrade
Secondaries are upgraded as recommended.
Primary upgrade move
The new database in data.new
on primary is moved back to its final data
directory.
Postupgrade
Database is started, can accept connections. After available, the operator updates all extensions in all databases, then runs ANALYZE
on all databases.