Skip to content

docs: guide for zero-downtime PostgreSQL major-version upgrade#37795

Open
tylerhartwig wants to merge 1 commit into
MaterializeInc:mainfrom
tylerhartwig:docs/postgres-major-version-upgrade
Open

docs: guide for zero-downtime PostgreSQL major-version upgrade#37795
tylerhartwig wants to merge 1 commit into
MaterializeInc:mainfrom
tylerhartwig:docs/postgres-major-version-upgrade

Conversation

@tylerhartwig

Copy link
Copy Markdown

Motivation

Users running a Materialize PostgreSQL source periodically need to upgrade the major version of the upstream database (e.g. PG 15 → 16). This is trickier than a normal upgrade because the source holds an active logical replication slot on the primary, and a major-version upgrade replaces that primary. There was no guidance for doing this while keeping Materialize fresh.

What this adds

A new guide, Guide: Upgrade the major version of your PostgreSQL source (ingest-data/postgres/major-version-upgrade.md), plus a link from the PostgreSQL guides index. It documents two approaches:

  • Parallel source (self-managed) — the only approach that keeps reads continuously fresh. Keep the existing source serving, feed a new-version primary via native logical replication, hydrate a second source in a separate schema in parallel, then do a coordinated cutover (freeze writes → drain → sync sequences → repoint consumers → resume).
  • Amazon RDS Blue/Green (managed) — simpler, with a bounded freshness gap. Documents two non-obvious constraints:
    • A Blue/Green deployment cannot be created while a Materialize source is attached to blue — the replication slot counts as external replication and RDS rejects it. The source must be dropped first (this starts the freshness gap).
    • After an in-place switchover, the source resumes from the same slot with no re-snapshot via ALTER CONNECTION ... SET (HOST = ...), because green is promoted in place (same LSN timeline).

A considerations section calls out the gotchas: DDL and sequences aren't replicated, REPLICA IDENTITY FULL is required, and ALTER CONNECTION only avoids a re-snapshot when the slot is preserved.

Validation

Both approaches were validated end-to-end against Amazon RDS PostgreSQL 15 → 16 under continuous insert/update/delete load, with an order-independent fingerprint (and a SUM(balance) transactional invariant for the self-managed path) confirming byte-consistency across the upstream databases and Materialize sources through cutover. hugo builds clean; all internal links resolve.

🤖 Generated with Claude Code

Add a guide covering how to upgrade the major version of the PostgreSQL
database behind a Materialize source. Documents two validated approaches:

- Parallel source (self-managed): keep the existing source serving fresh
  while native logical replication feeds a new-version primary and a second
  source hydrates in parallel, then cut consumers over. Only approach that
  keeps reads continuously fresh.
- Amazon RDS Blue/Green: managed cutover with a bounded freshness gap.
  Documents that Materialize's replication slot counts as "external
  replication" (so the source must be dropped before the deployment can be
  created), and that after an in-place switchover the source can resume from
  the same slot via ALTER CONNECTION ... SET (HOST = ...) with no re-snapshot.

Both approaches and their gotchas (DDL/sequences not replicated, REPLICA
IDENTITY FULL, slot-preservation semantics of ALTER CONNECTION) were
validated end-to-end against RDS PostgreSQL 15->16.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@tylerhartwig
tylerhartwig requested a review from a team as a code owner July 21, 2026 18:47
Comment on lines +180 to +182
1. `DROP SOURCE` in Materialize to release the replication slot. Confirm
`pg_replication_slots` no longer lists Materialize's slot. **The freshness
gap starts here.**

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let alone freshness gap, won't this cascade drop all the downstream objects and cause an availability incident?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants