Repository navigation
feat: add images and settings to create primary-replica PostgreSQL - #405
Open
NingZhou-NZ wants to merge 1 commit into
Open
NingZhou-NZ wants to merge 1 commit into
NingZhou-NZ wants to merge 1 commit into
Conversation
NingZhou-NZ
force-pushed
the
feat-primary-replica-postgres
branch
from
August 18, 2026 11:46
730ad3b to
878e2e1
Compare
codyfinegan
force-pushed
the
feat-primary-replica-postgres
branch
from
October 8, 2026 20:16
878e2e1 to
4454fc8
Compare
codyfinegan
requested changes
Oct 8, 2026
codyfinegan
left a comment
Member
There was a problem hiding this comment.
- No replication slot, so the replica breaks for good after a gap. I stopped the replica, wrote about 1.2M rows on the primary with WAL switches and checkpoints, then started it again. It loops on requested WAL segment 000000010000000000000003 has already been removed. Settings are wal_keep_size = 0 and no slots. A Totara install or upgrade writes far more WAL than my test. The only way to recover is to delete the replica volume.
- Fix: add -C -S replica_1 to pg_basebackup and set max_slot_wal_keep_size on the primary. Setting wal_keep_size = 1GB would also work.
- The primary does not get the Totara lock settings. my-postgres-master.conf does not include max_locks_per_transaction = 1024 / max_pred_locks_per_transaction = 1024 from my-postgres.conf. The primary shows 64, the replica 1024. The primary is where Totara writes.
- Fix: add them to the master conf, or include the base conf.
- Partial pg_basebackup is treated as a valid data directory. If the backup dies after PG_VERSION is written, the next start skips init and boots a broken data dir. Low risk for dev.
- Fix: back up into a temp dir and move it into place, or write a marker file when the backup finishes.
Minor
- The filename is misspelled: pgsql/init/creare-replicator.sql should be create-replicator.sql.
- pg_isready -U replicator with no -d logs FATAL: database "replicator" does not exist on the primary on every poll. Add -d postgres.
- hot_standby = on in the primary conf does nothing on a primary.
- The two new services do not follow compose/pgsql.yml: no <<: *postgres-healthcheck and no restart: ${RESTART_POLICY:-no}.
- Naming mixes "master" and "primary": my-postgres-master.conf and pgsql16-master-data vs service pgsql-primary. The ports 54320/54321 also don't follow the 54XX version scheme.
- replica_password is hardcoded in both the SQL file and the entrypoint. One env var would keep them in sync.
- No docs. A short note with the Totara config.php snippet would help: dbhost = 'pgsql-primary' and $CFG->dboptions['readonly'] pointing at pgsql-replica-1.
- None of the new files end with a newline.
Fix items 1 and 2 before merge.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Describe what this pull request is about
Testing Instructions
tup pgsql-primary pgsql-replica-1config.phpAnd extra setting at the end of
config.phpChecklist
bin/directory run correctly on both MacOS and WSLtbuild container && tup container)config.phpare compatible with our oldest supported Totara version, our newest Totara version, and Moodle