Skip to content

This is the multi-page printable view of this section.

Return to the regular view of this page

How-to Guides

Task-oriented operational playbooks for instance planning, client authentication, backups, extensions, and replication failover.

Use these task-oriented guides when planning deployments, configuring authentication, rehearsing backups, building extensions, or operating active-active clusters.

1 - Instance profiles, ports and authentication

Select one compatibility profile per instance, plan protocol ports, and verify PostgreSQL and wire-protocol authentication.

Select an instance profile

Every Mimus instance retains its native PostgreSQL listener (5432) for administration, backup, and native SQL clients. In addition, choose at most one session or document compatibility profile per PGDATA directory:

Instance profileshared_preload_libraries baselineClient ports
Native PostgreSQL(empty, or pg_tde, spock)5432
MySQL compatiblepg_mysql (plus optional pg_tde, spock)5432, 3306
MSSQL compatiblebabelfishpg_tds (plus optional pg_tde, spock)5432, 1433
MongoDB gatewaypg_cron, DocumentDB (single-node)5432, 27017 (gateway)

Service gateways that require zero kernel patches (pgredis, pgetcd, pgsilo) connect over standard PostgreSQL pools and load their companion extensions (pg_redis, pg_etcd, or silo schemas) on stock or Mimus instances.

Plan default and co-located ports

When running multiple services or Pigsty infrastructure agents on the same host, check default port assignments before binding listeners:

Protocol / ServiceProtocol defaultCommon host note
PostgreSQL5432Native administration and SQL
MySQL (pg_mysql)3306Configurable via mysql.port
MSSQL (Babelfish)1433Configurable via babelfishpg_tds.port
MongoDB (DocumentDB gateway)27017Standalone gateway listener
Redis (pgredis)6379Gateway defaults to 127.0.0.1:56379 in local labs
etcd (pgetcd)2379 / 2381Collides with host etcd DCS if Patroni runs locally
S3 (pgsilo)9000 / 9001Shares default MinIO / Silo object and console ports

Verify native and compatibility authentication

Before enabling compatibility extensions, verify native login, account identity, and build version using the psql binary from your Mimus installation:

psql -X -c 'SELECT current_database(), current_user, version()'
psql -X -c 'SHOW mimus_required_features'

Role access on port 5432 follows standard PostgreSQL 19 client authentication (pg_hba.conf, scram-sha-256, TLS). MySQL (3306) and TDS (1433) listeners negotiate their own wire handshakes (caching_sha2_password / mysql_native_password for MySQL; TDS login mappings for Babelfish), so always verify login separately through the target client driver after configuring native roles.

2 - Backup, restore and encrypted recovery

Back up Mimus clusters safely, maintain encryption key custody across rotations, restore DocumentDB dumps, and observe encrypted-WAL standby limits.

Run physical backups and offline page checks

Use pg_basebackup from the matching /usr/mimus-19/bin installation to take physical backups of Mimus clusters, including instances with pg_tde, spock, pg_mysql, or Babelfish enabled:

/usr/mimus-19/bin/pg_basebackup -D /var/backups/mimus-base -Fp -Xs -P -R

On encrypted clusters, physical pages on disk contain ciphertext. Standard checksum tools that are unaware of pg_tde cannot inspect encrypted page payloads directly; always use the Mimus toolchain built with layer 100 / 101 storage hooks and rehearse independent restore into a separate host before relying on a backup chain.

Guard historical keys alongside WAL

Rotating a principal key re-wraps internal relation keys, while historical WAL segments and older base backups still depend on earlier principal key versions during point-in-time recovery (PITR).

  • Never delete or purge retired key versions from Vault, KMIP, or file keyrings while any physical backup or archived WAL referencing them remains within your retention window.
  • Store your Mimus kernel revision, extension git trees, and SHOW mimus_required_features output in your backup manifest. See Back up, restore and migrate for full runbooks.

Logical pg_restore for single-node DocumentDB

When restoring a pg_dump archive from a single-node DocumentDB instance into a fresh target, handle pg_cron background jobs with one of two verified procedures:

  1. Use fresh default jobs: Run pg_restore -N cron to skip archived cron rows and keep the target installation’s default jobs.
  2. Preserve archived job history: Pause job scheduling on the clean target, run CREATE EXTENSION documentdb CASCADE and unschedule its four newly created default jobs in one transaction, restore the full archive, and resume scheduling.

Observe encrypted-WAL replication boundaries

When cluster-wide WAL encryption (pg_tde.wal_encrypt = on) is enabled on 19.0.1-r4:

  • Cascading physical replication (standby streaming to another downstream standby) is unsupported.
  • Standby mid-segment restart: A physical standby that restarts and re-streams from the beginning of an encrypted WAL segment is excluded in 19.0.1-r4; provision fresh base backups or evaluate plaintext WAL over TLS links when standby restarts are routine.
  • MSSQL temporary objects: On Babelfish instances, T-SQL #temp tables, @table variables, and sort/hash workfiles use ordinary heap storage and can reach disk in plaintext; see Temporary storage and plaintext on disk.

3 - Build extensions, run REPACK and validate workloads

Compile C and Rust pgrx extensions against Mimus pg_config, reorganize tables safely with native PostgreSQL 19 REPACK, and test application SQL.

Choosing extension binaries

Build native C and Rust (pgrx 0.20.1) extensions using the pg_config binary and server headers from the target /usr/mimus-19 installation:

export PATH="/usr/mimus-19/bin:$PATH"
make PG_CONFIG=/usr/mimus-19/bin/pg_config
sudo make PG_CONFIG=/usr/mimus-19/bin/pg_config install

A shared PostgreSQL 19 major version establishes the SQL baseline, not universal drop-in ABI compatibility with prebuilt third-party binaries, because the unified Mimus kernel includes Babelfish parser/executor hooks alongside storage and replication interfaces. pgrx 0.20.1 header compatibility is verified against Mimus 19.0.1-r4 (790 PG 19 tests passed). For workloads requiring Citus or TimescaleDB, deploy a separate community PostgreSQL cluster.

Validating a workload

Before migrating an application, run an end-to-end check against your chosen listener and storage configuration:

  1. Exercise driver connection startup, TLS negotiation, authentication, and parameter binding.
  2. Run representative schema DDL, concurrent reads/writes, generated keys, null handling, and collation comparisons from both the compatibility protocol (MySQL, MSSQL, or MongoDB) and native psql.
  3. Take a backup, restore it into a second isolated instance, and re-run application smoke checks against the restored data. See 19.0.1-r4 Verification for tested combinations.

Storage and third-party extensions

Mimus excludes OrioleDB, Citus, and TimescaleDB (including when pg_tde is disabled).

For online or offline table reorganization on PostgreSQL 19, always use PostgreSQL 19’s built-in REPACK command rather than the external pg_repack extension. In verification testing, external pg_repack 1.5.3 rewrote tde_heap tables back into unencrypted ordinary heap storage while queries continued returning rows without warning. After any table rewrite, verify encryption on the relation, indexes, and TOAST table with pg_tde_is_encrypted(); see PG TDE table coverage.

4 - Conflict resolution and standby failover

Choose deterministic conflict rules for bidirectional Spock replication, monitor apply workers, and rehearse standby promotion.

Choose conflict arbitration rules

Asynchronous multi-master replication allows two nodes to commit writes to the same row before replicating to each other. Before adding a table to a spock replication set, configure track_commit_timestamp = on on every node and match each table column pattern to a deterministic conflict rule:

  • Last-update-wins (last_update_wins): Resolves concurrent INSERT/UPDATE conflicts using commit timestamps; Mimus kernel layers 200 / 201 preserve surviving subtransaction commit timestamps inside COMMIT WAL so physical standbys see identical timestamps.
  • Delta-apply (spock.delta_apply): For numeric counters and balances, enable log_old_value = true and delta_apply_function = spock.delta_apply on the column so concurrent increments and decrements commute cleanly.
  • Distributed IDs: Avoid colliding SERIAL sequences across writable nodes by assigning disjoint sequence ranges, UUIDs, or the pgEdge Snowflake extension.

Monitor subscriptions and conflict logs

Check subscription state, replication slot lag, and recorded conflict history on every writable node:

SELECT subscription_name, status FROM spock.sub_show_status();
SELECT slot_name, active, confirmed_flush_lsn,
       pg_size_pretty(pg_wal_lsn_diff(pg_current_wal_lsn(), restart_lsn)) AS retained
  FROM pg_replication_slots WHERE plugin = 'spock_output';
SELECT relname, conflict_type, conflict_resolution, local_timestamp, remote_timestamp
  FROM spock.resolutions ORDER BY id DESC LIMIT 10;

See pgEdge conflict operations for detailed diagnostics.

Rehearse physical standby promotion

When pairing Spock logical nodes with local physical HA standbys:

  • Ensure every physical standby runs a Mimus kernel built through layer 201 (or full 401) so it can replay Spock’s custom COMMIT WAL records generated during subtransaction conflict resolution; stock community PostgreSQL binaries cannot replay those records.
  • Synchronize logical replication slot positions (sync_replication_slots or controlled slot failover) and encryption key providers on standbys before rehearsing promotion; see pgEdge recovery boundaries.