Skip to content

Design Doc: Upgrade of the major version of postgres #11

@duanhongyi

Description

@duanhongyi

Design Doc

This is a design document for the upgrade of the major version of postgres(#12).

Goal

As we all know, workflow database uses postgresql, but at present it is still postgresql-9.4. How to establish a long-term upgrade mechanism is the main problem to be solved in this design. The goal of this design is to ensure seamless auto upgrade of major postgresql, the main implementation mechanism is using pg_upgrade tool.

Off-Cluster Storage Required

A Workflow upgrade requires using off-cluster object storage, since the default
in-cluster storage is ephemeral. Upgrading Workflow with the in-cluster default
of Minio will result in data loss.

See: https://docs.teamhephy.com/installing-workflow/configuring-object-storage/

Code Change

  • Modify Dockerfile to use postgres:11-alpine, and add PGDATA_RECOVERY to docker image.
  • Adding rootfs/bin/do_upgrade is used to implement the main upgrade function, because the old database is needed on the pg_upgrade mechanism, so the previous database binary program needs to be downloaded.
  • The upgrade mainly involves two main branches:
    • One is the cluster using gluster/ceph and other block storage services, the upgrade scheme is detailed in rootfs/docker-entrypoint.sh.
    • The other rootfs/docker-entrypoint-initdb.d/003_restore_from_backup.sh, is using WALE to upgrade.
  • For data security reasons, the PGDATA_RECOVERY content will not be deleted after the upgrade is successful. After confirming that there is no problem, it needs to be deleted manually, and not deleting it will not affect the service.

Tests

I added some test cases to ensure its robustness, which will run with the make test command. See in detail postgres/contrib/ci/test-upgrade.sh

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions