PostgreSQL Support — What's Needed to Make It Real
Current state
We have:
DatabaseProvider interface (go/inst/provider.go)
PostgreSQLProvider implementation (go/inst/provider_postgresql.go)
- Config fields:
PostgreSQLTopologyUser, PostgreSQLTopologyPassword, PostgreSQLSSLMode
We do NOT have:
- The core orchestrator loop using the provider interface (it calls MySQL DAOs directly)
- Any functional testing against real PostgreSQL
- PostgreSQL-specific analysis codes (failure detection)
- PostgreSQL-specific recovery logic
- Tutorials or documentation for real usage
Implementation phases
Phase A: Wire provider into discovery loop
Estimated effort: 2-3 days
The discovery loop in go/logic/orchestrator.go and go/inst/instance_dao.go calls MySQL-specific functions directly. We need to:
- Add a
ProviderType config field ("mysql" or "postgresql", default "mysql")
- In
ReadTopologyInstance() (go/inst/instance_dao.go), branch based on provider type:
- MySQL path: existing code (unchanged)
- PostgreSQL path: call
GetProvider().GetReplicationStatus() etc.
- Map PostgreSQL replication concepts to orchestrator's internal model:
- Primary → Master
- Standby → Replica
- WAL LSN → replication position
pg_stat_replication → replica list
pg_stat_wal_receiver → replication status
- Store discovered PostgreSQL instances in the same
instance table
Key challenge: Orchestrator's Instance struct has many MySQL-specific fields (binlog coordinates, GTID sets, etc.). Need to decide: extend the struct with PG fields, or use the provider abstraction to normalize.
Phase B: PostgreSQL failure detection
Estimated effort: 2-3 days
- Add PostgreSQL-specific analysis codes:
DeadPrimary (equivalent to DeadMaster)
StandbyNotReplicating
PrimaryReadOnly
- Implement PostgreSQL failure detection in
go/inst/analysis_dao.go
- PostgreSQL detection relies on:
- Can we connect to the primary?
- Are standbys receiving WAL?
- Is
pg_stat_replication showing connected standbys?
Phase C: PostgreSQL recovery
Estimated effort: 3-5 days
- Implement
pg_promote() for standby promotion
- Reconfigure remaining standbys to follow the new primary (
primary_conninfo in postgresql.auto.conf + pg_reload_conf())
- Handle timeline changes after promotion
- Pre/post recovery hooks (same mechanism as MySQL)
- Integration with PgBouncer (similar to ProxySQL hooks for MySQL)
Phase D: Functional testing
Estimated effort: 2-3 days
- Add PostgreSQL containers to
tests/functional/docker-compose.yml:
- PostgreSQL primary + 2 streaming replicas
- PgBouncer (optional)
- Test scripts:
- Discovery of PostgreSQL topology
- Failure detection (stop primary)
- Automatic promotion of standby
- Replication reconfiguration
- Add to GitHub Actions functional test workflow
Phase E: Documentation and tutorials
Estimated effort: 1-2 days
- Tutorial: "Setting up orchestrator with PostgreSQL streaming replication"
- Update reference manual with PostgreSQL config fields
- Update website features page
- Blog post / announcement
Total estimated effort: 10-16 days
Dependencies and risks
- Risk: The
Instance struct is deeply MySQL-centric. A clean abstraction may require significant refactoring of the struct itself, not just the DAO layer.
- Risk: PostgreSQL replication management tools (Patroni, repmgr) are mature. Orchestrator needs to offer a clear value proposition for PostgreSQL users.
- Dependency: Phase A must complete before B/C. D can start after C. E after D.
Success criteria
PostgreSQL support is "real" when:
PostgreSQL Support — What's Needed to Make It Real
Current state
We have:
DatabaseProviderinterface (go/inst/provider.go)PostgreSQLProviderimplementation (go/inst/provider_postgresql.go)PostgreSQLTopologyUser,PostgreSQLTopologyPassword,PostgreSQLSSLModeWe do NOT have:
Implementation phases
Phase A: Wire provider into discovery loop
Estimated effort: 2-3 days
The discovery loop in
go/logic/orchestrator.goandgo/inst/instance_dao.gocalls MySQL-specific functions directly. We need to:ProviderTypeconfig field ("mysql"or"postgresql", default"mysql")ReadTopologyInstance()(go/inst/instance_dao.go), branch based on provider type:GetProvider().GetReplicationStatus()etc.pg_stat_replication→ replica listpg_stat_wal_receiver→ replication statusinstancetableKey challenge: Orchestrator's
Instancestruct has many MySQL-specific fields (binlog coordinates, GTID sets, etc.). Need to decide: extend the struct with PG fields, or use the provider abstraction to normalize.Phase B: PostgreSQL failure detection
Estimated effort: 2-3 days
DeadPrimary(equivalent toDeadMaster)StandbyNotReplicatingPrimaryReadOnlygo/inst/analysis_dao.gopg_stat_replicationshowing connected standbys?Phase C: PostgreSQL recovery
Estimated effort: 3-5 days
pg_promote()for standby promotionprimary_conninfoinpostgresql.auto.conf+pg_reload_conf())Phase D: Functional testing
Estimated effort: 2-3 days
tests/functional/docker-compose.yml:Phase E: Documentation and tutorials
Estimated effort: 1-2 days
Total estimated effort: 10-16 days
Dependencies and risks
Instancestruct is deeply MySQL-centric. A clean abstraction may require significant refactoring of the struct itself, not just the DAO layer.Success criteria
PostgreSQL support is "real" when:
orchestrator -c discoverdiscovers a PostgreSQL primary + standbys