================ Source: https://mimus.pgsty.com/docs/index.md ================ # Documentation > Tutorials, operational how-to guides, architecture concepts, reference matrices, and per-protocol manuals for Mimus on PostgreSQL 19.0. --- LLMS index: [llms.txt](/llms.txt) --- Mimus unifies multiple wire protocols, transparent storage encryption, multi-master replication, and the PostgreSQL extension ecosystem on a single **PostgreSQL 19.0** foundation. The manual is organized into four quadrants, followed by dedicated capability and protocol guides. ## Four quadrants {#quadrants} - [Tutorials](/docs/tutorials/) (Start here) — Runnable step-by-step labs: build Mimus from source, share a table across MySQL and psql, encrypt a table, and wire up two writable nodes. - [How\-to Guides](/docs/guides/) (Operations) — Task-oriented playbooks for instance profiles, authentication, physical backup and key custody, native REPACK, and failover. - [Concepts \& Architecture](/docs/concepts/) (Design) — Why session protocols use kernel hooks while high-concurrency services use gateways, and how isolation rules and feature locks work. - [Reference](/docs/reference/) (Specs) — Protocol and port matrix, GUC parameter tables, 19.0.1-r4 acceptance data, and the 000–401 kernel patch manifest. ## Core engine capabilities {#capabilities} - [PG TDE](/docs/tde/) (pg\_tde 2\.3) — Transparent encryption for heap tables, B-tree indexes, TOAST data, and cluster WAL via local file, Vault, or KMIP keys, plus the upstream Percona manual. - [pgEdge](/docs/spock/) (Spock 5\.0\.15) — Asynchronous multi-master logical replication across writable PostgreSQL 19 nodes with deterministic conflict rules, plus Spock, LOLOR, SafeSession, and Snowflake manuals. ## Wire protocols and gateways {#protocols} - [MySQL](/docs/mysql/) (3306 · Verified) — OpenHalo session protocol hook and `pg_mysql 1.0` mapping MySQL databases directly onto PostgreSQL schemas. - [MSSQL](/docs/mssql/) (1433 · Verified) — Babelfish for PostgreSQL serving TDS logins and T-SQL procedures, including encrypted permanent tables. - [MongoDB](/docs/mongo/) (27017 · Verified) — Single-node DocumentDB 1.2 storing BSON collections in PostgreSQL tables behind a standalone MongoDB gateway. - [Redis](/docs/redis/) (6379 · RC) — `pgredis` Go gateway and `pg_redis` extension allowing Redis 7 commands to join SQL transactions. - [etcd](/docs/etcd/) (2379 · RC) — `pgetcd` gRPC gateway and `pg_etcd` extension keeping revisions, Watches, and Leases in PostgreSQL tables. - [S3](/docs/s3/) (9000 · MVP) — `pgsilo` object backend on Silo storing object segments, versions, and IAM policies inside PostgreSQL. - [Kafka](/docs/kafka/) (9092 · Explore) — Open architectural design notes on mapping partitioned logs and consumer offsets onto PostgreSQL. - [Protocol Matrix](/docs/reference/matrix/) (5432 · Native) — Compare all eight protocols side by side, including native PostgreSQL 5432, kernel requirements, and licenses. --- Section pages: - [Tutorials](/docs/tutorials/): Hands-on, step-by-step labs from building Mimus 19.0.1 to running multi-protocol, encrypted and active-active workloads. - [How-to Guides](/docs/guides/): Task-oriented operational playbooks for instance planning, client authentication, backups, extensions, and replication failover. - [Concepts & Architecture](/docs/concepts/): Why Mimus unifies session wire hooks, stateless service gateways, encryption, replication and extensions on one PostgreSQL 19.0 kernel. - [Reference](/docs/reference/): Authoritative lookup tables for Mimus wire protocols, server parameters, 19.0.1-r4 verification results, and the nine kernel patch layers. - [PG TDE](/docs/tde/): Encrypt selected tables with pg_tde 2.3 and plan for recovery with the original keys. - [pgEdge](/docs/spock/): Set up bidirectional active-active logical replication with pgEdge Spock 5.0.15 and understand its recovery boundary. - [MySQL](/docs/mysql/): Connect a MySQL application to Mimus 19.0.1 and read the same tables with PostgreSQL. - [MSSQL (Babelfish)](/docs/mssql/): Connect MSSQL (SQL Server) clients to Mimus 19.0.1 over TDS 1433 via Babelfish for PostgreSQL and assess T-SQL workloads. - [MongoDB](/docs/mongo/): Single-node DocumentDB 1.2 gateway verified in 19.0.1-r4, plus historical PG18 and FerretDB deployment notes. - [Redis](/docs/redis/): Redis commands through the pgredis gateway, with data in PostgreSQL tables. - [etcd](/docs/etcd/): etcd v3 gRPC through the pgetcd gateway, with revisions and leases in tables. - [S3](/docs/s3/): S3 object storage through pgsilo, Silo's PostgreSQL backend, with an SQL API. - [Kafka](/docs/kafka/): Kafka protocol on PostgreSQL: an open question, with no design or code yet. ================ Source: https://mimus.pgsty.com/docs/tutorials/index.md ================ # Tutorials > Hands-on, step-by-step labs from building Mimus 19.0.1 to running multi-protocol, encrypted and active-active workloads. --- LLMS index: [llms.txt](/llms.txt) --- Start here when trying Mimus for the first time. Each tutorial walks through one runnable lab from start to finish and verifies the result with standard client tools. 1. [Build and start Mimus](/docs/tutorials/build-and-run/) — Compile the PostgreSQL 19.0 kernel and `pg_mysql` from source, initialize `PGDATA`, and inspect `mimus_required_features`. 2. [Shared table across MySQL and PostgreSQL](/docs/tutorials/shared-table/) — Write rows on TCP `3306` with `mysql` and read them back on TCP `5432` with `psql`. 3. [Encrypt your first table with PG TDE](/docs/tutorials/encrypt-first-table/) — Register a keyring provider, create a `USING tde_heap` table, and verify relation encryption. 4. [Two-node active-active lab with pgEdge](/docs/tutorials/active-active-nodes/) — Pair two writable nodes with Spock 5.0.15 and merge concurrent `delta_apply` balance updates. {.steps} --- Section pages: - [Build and start Mimus](/docs/tutorials/build-and-run/): Compile Mimus 19.0.1 and pg_mysql from the public Git trees, initialize a data directory, and verify native PostgreSQL connectivity. - [Shared table across MySQL and PostgreSQL](/docs/tutorials/shared-table/): Enable the MySQL listener on port 3306, write rows from a MySQL client, and query the same table from psql on port 5432. - [Encrypt your first table with PG TDE](/docs/tutorials/encrypt-first-table/): Configure a keyring provider, create an encrypted table using tde_heap, and verify transparent page encryption and startup protection. - [Two-node active-active lab with pgEdge](/docs/tutorials/active-active-nodes/): Start two local Mimus nodes with Spock 5.0.15, establish bidirectional replication, and verify delta_apply conflict merging. ================ Source: https://mimus.pgsty.com/docs/tutorials/build-and-run/index.md ================ # Build and start Mimus > Compile Mimus 19.0.1 and pg_mysql from the public Git trees, initialize a data directory, and verify native PostgreSQL connectivity. --- LLMS index: [llms.txt](/llms.txt) --- ## Prerequisites {#prereqs} You need a Linux host (Debian 13, Ubuntu 24.04/26.04, or Rocky Linux 9/10) with standard PostgreSQL build dependencies: a C11 compiler (`gcc` or `clang`), `meson` / `ninja` or GNU `make`, `bison`, `flex`, `libreadline-dev`, `zlib1g-dev`, `libssl-dev`, `libicu-dev`, `libxml2-dev`, and `pkg-config`. ## Compile the kernel and pg_mysql {#build} Clone the public [pgsty/mimus](https://github.com/pgsty/mimus) kernel repository and the companion [pgsty/pg_mysql](https://github.com/pgsty/pg_mysql) extension repository, check out the verified `19.0.1-r4` revisions, and install under `/usr/mimus-19`: ```sh git clone https://github.com/pgsty/mimus.git cd mimus && git checkout 0d8a551aa121 ./configure --prefix=/usr/mimus-19 --with-ssl=openssl --with-icu --with-libxml make -j"$(nproc)" sudo make install cd .. git clone https://github.com/pgsty/pg_mysql.git cd pg_mysql && git checkout 1e631f9802c5 make -j"$(nproc)" PG_CONFIG=/usr/mimus-19/bin/pg_config sudo make PG_CONFIG=/usr/mimus-19/bin/pg_config install ``` > [!TIP] Additional extensions > To add `pg_tde`, `spock` or `Babelfish` onto the same `/usr/mimus-19` prefix, build each extension against `/usr/mimus-19/bin/pg_config` using the matched source trees listed in [Kernel Patch Manifest](/docs/reference/patches/base/#components). ## Initialize and verify the instance {#verify} Create a fresh data directory, start the server on port `5432`, and inspect the version and cluster feature state: ```sh export PATH="/usr/mimus-19/bin:$PATH" initdb -D /var/lib/mimus/data --auth-local=peer --auth-host=scram-sha-256 --encoding=UTF8 pg_ctl -D /var/lib/mimus/data -l /var/lib/mimus/logfile start psql -X -d postgres -c "SELECT current_database(), current_user, version();" psql -X -d postgres -c "SHOW mimus_required_features;" ``` On a freshly initialized cluster before any optional compatibility or encryption feature is activated, `mimus_required_features` returns an empty string, meaning the directory remains a plain PostgreSQL 19.0 data directory. Next, continue to [Shared table across MySQL and PostgreSQL](/docs/tutorials/shared-table/) to enable the MySQL wire listener on this instance. --- Backlinks: - [Verification Matrix](/docs/reference/verification/) - [Tutorials](/docs/tutorials/) - [Shared MySQL & PG Table](/docs/tutorials/shared-table/) ================ Source: https://mimus.pgsty.com/docs/tutorials/shared-table/index.md ================ # Shared table across MySQL and PostgreSQL > Enable the MySQL listener on port 3306, write rows from a MySQL client, and query the same table from psql on port 5432. --- LLMS index: [llms.txt](/llms.txt) --- ## Preload pg_mysql {#preload} Starting from the instance created in [Build and start Mimus](/docs/tutorials/build-and-run/), preload `pg_mysql`, enable the MySQL wire listener on port `3306`, set a login password, and create the SQL extension inside `postgres`: ```sh psql -X -d postgres <<'SQL' ALTER SYSTEM SET shared_preload_libraries = 'pg_mysql'; ALTER SYSTEM SET mysql.listener_on = on; ALTER SYSTEM SET mysql.port = 3306; ALTER SYSTEM SET mysql.database = 'postgres'; ALTER ROLE postgres WITH PASSWORD 'ChangeMe_Lab_2026!'; SQL pg_ctl -D /var/lib/mimus/data restart psql -X -d postgres -c "CREATE EXTENSION pg_mysql;" ``` Ensure `pg_hba.conf` permits local TCP logins (`scram-sha-256` or `md5`) from `127.0.0.1/32`. ## Create and populate a table from MySQL {#mysql-write} Connect with the standard `mysql` command-line client on TCP `3306`, create a logical MySQL database `app`, and insert two rows: ```sh mysql -h 127.0.0.1 -P 3306 -u postgres -p'ChangeMe_Lab_2026!' <<'SQL' CREATE DATABASE app; USE app; CREATE TABLE notes ( id INT PRIMARY KEY AUTO_INCREMENT, body VARCHAR(40) NOT NULL ); INSERT INTO notes (body) VALUES ('written over 3306'), ('shared MVCC row'); SELECT DATABASE(), @@version, @@version_comment; SQL ``` Each logical MySQL database maps to a PostgreSQL schema inside `mysql.database` (`postgres` by default). ## Query the same physical table from PostgreSQL {#psql-read} Now read and join those exact committed rows over native PostgreSQL on port `5432`: ```sh psql -X -h 127.0.0.1 -p 5432 -U postgres -d postgres \ -c "SELECT id, body FROM app.notes ORDER BY id;" ``` ```text id | body ----+------------------- 1 | written over 3306 2 | shared MVCC row (2 rows) ``` Both sessions share one buffer pool, one WAL stream, and one physical relation (`app.notes`). For driver details, TLS setup and SQL dialect rules, see the [MySQL manual](/docs/mysql/). --- Backlinks: - [Tutorials](/docs/tutorials/) - [Build & Start Mimus](/docs/tutorials/build-and-run/) ================ Source: https://mimus.pgsty.com/docs/tutorials/encrypt-first-table/index.md ================ # Encrypt your first table with PG TDE > Configure a keyring provider, create an encrypted table using tde_heap, and verify transparent page encryption and startup protection. --- LLMS index: [llms.txt](/llms.txt) --- ## Configure preloading and a local keyring {#provider} On an instance with `pg_tde` installed under `/usr/mimus-19`, add `pg_tde` to `shared_preload_libraries`, restart PostgreSQL, and register a local keyring file for your lab database: ```sh sudo install -d -m 0700 -o postgres -g postgres /var/lib/mimus-keys psql -X -d postgres -c "ALTER SYSTEM SET shared_preload_libraries = 'pg_tde';" pg_ctl -D /var/lib/mimus/data restart ``` Now enable the extension and bind a principal key in `postgres`: ```sql CREATE EXTENSION pg_tde WITH SCHEMA public; SELECT pg_tde_add_database_key_provider_file( 'lab_provider', '/var/lib/mimus-keys/lab.per'); SELECT pg_tde_create_key_using_database_key_provider( 'lab_key', 'lab_provider'); SELECT pg_tde_set_key_using_database_key_provider( 'lab_key', 'lab_provider'); ``` > [!IMPORTANT] Production key management > File providers are intended for local testing and development. Production deployments should store principal keys in HashiCorp Vault or a KMIP server; see [Keys and WAL encryption](/docs/tde/keys/). ## Create and verify an encrypted table {#encrypt} Create a table with `USING tde_heap` plus an index and out-of-line text, then confirm encryption status: ```sql CREATE TABLE public.ledger ( id integer PRIMARY KEY, memo text NOT NULL, balance bigint NOT NULL ) USING tde_heap; INSERT INTO public.ledger VALUES (1, repeat('confidential-', 200), 50000); SELECT pg_tde_is_encrypted('public.ledger'::regclass); ``` `pg_tde_is_encrypted` returns `t`. Primary heap pages, the primary-key B-tree index, and the TOAST table are all encrypted on disk while remaining transparent to SQL, MySQL (`pg_mysql`), and TDS (`Babelfish`) queries. ## Check the cluster startup guard {#guard} Inspect the cluster's recorded feature lock: ```sql SHOW mimus_required_features; -- Returns: tde ``` Once `tde` is recorded in `mimus_required_features`, Mimus refuses to start or replay WAL against this data directory if `pg_tde` is omitted from `shared_preload_libraries`, preventing accidental startup without storage decryption hooks. For backup and offline page verification, continue to the [PG TDE manual](/docs/tde/). --- Backlinks: - [Tutorials](/docs/tutorials/) ================ Source: https://mimus.pgsty.com/docs/tutorials/active-active-nodes/index.md ================ # Two-node active-active lab with pgEdge > Start two local Mimus nodes with Spock 5.0.15, establish bidirectional replication, and verify delta_apply conflict merging. --- LLMS index: [llms.txt](/llms.txt) --- ## Initialize two writable nodes {#nodes} With Spock 5.0.15 installed under `/usr/mimus-19`, initialize two local instances on ports `5541` (`node_a`) and `5542` (`node_b`) with logical WAL and commit timestamps enabled: ```sh for p in 5541 5542; do initdb -D "/tmp/mimus-${p}" --auth-local=trust --auth-host=trust cat >> "/tmp/mimus-${p}/postgresql.conf" < Task-oriented operational playbooks for instance planning, client authentication, backups, extensions, and replication failover. --- LLMS index: [llms.txt](/llms.txt) --- Use these task-oriented guides when planning deployments, configuring authentication, rehearsing backups, building extensions, or operating active-active clusters. - [Instance profiles, ports and authentication](/docs/guides/instance-planning/) — Select your listener profile, assign non-colliding ports, and verify native and compatibility authentication. - [Backup, restore and encrypted recovery](/docs/guides/backup-and-recovery/) — Run physical backups, preserve historical encryption keys, restore DocumentDB archives, and stay within WAL limits. - [Build extensions, run REPACK and validate workloads](/docs/guides/extensions/) — Compile C and Rust (`pgrx`) modules against Mimus `pg_config`, reorganize encrypted tables safely, and test client SQL. - [Conflict resolution and standby failover](/docs/guides/failover-and-conflicts/) — Configure deterministic conflict rules, monitor Spock replication lag, and rehearse physical standby promotion. {.cards} --- Section pages: - [Instance profiles, ports and authentication](/docs/guides/instance-planning/): Select one compatibility profile per instance, plan protocol ports, and verify PostgreSQL and wire-protocol authentication. - [Backup, restore and encrypted recovery](/docs/guides/backup-and-recovery/): Back up Mimus clusters safely, maintain encryption key custody across rotations, restore DocumentDB dumps, and observe encrypted-WAL standby limits. - [Build extensions, run REPACK and validate workloads](/docs/guides/extensions/): Compile C and Rust pgrx extensions against Mimus pg_config, reorganize tables safely with native PostgreSQL 19 REPACK, and test application SQL. - [Conflict resolution and standby failover](/docs/guides/failover-and-conflicts/): Choose deterministic conflict rules for bidirectional Spock replication, monitor apply workers, and rehearse standby promotion. ================ Source: https://mimus.pgsty.com/docs/guides/instance-planning/index.md ================ # Instance profiles, ports and authentication > Select one compatibility profile per instance, plan protocol ports, and verify PostgreSQL and wire-protocol authentication. --- LLMS index: [llms.txt](/llms.txt) --- ## Select an instance profile {#profiles} 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 profile | `shared_preload_libraries` baseline | Client ports | | --- | --- | --- | | Native PostgreSQL | *(empty, or `pg_tde`, `spock`)* | `5432` | | MySQL compatible | `pg_mysql` *(plus optional `pg_tde`, `spock`)* | `5432`, `3306` | | MSSQL compatible | `babelfishpg_tds` *(plus optional `pg_tde`, `spock`)* | `5432`, `1433` | | MongoDB gateway | `pg_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 {#ports} When running multiple services or Pigsty infrastructure agents on the same host, check default port assignments before binding listeners: | Protocol / Service | Protocol default | Common host note | | --- | --- | --- | | PostgreSQL | `5432` | Native administration and SQL | | MySQL (`pg_mysql`) | `3306` | Configurable via `mysql.port` | | MSSQL (`Babelfish`) | `1433` | Configurable via `babelfishpg_tds.port` | | MongoDB (`DocumentDB` gateway) | `27017` | Standalone gateway listener | | Redis (`pgredis`) | `6379` | Gateway defaults to `127.0.0.1:56379` in local labs | | etcd (`pgetcd`) | `2379` / `2381` | Collides with host etcd DCS if Patroni runs locally | | S3 (`pgsilo`) | `9000` / `9001` | Shares default MinIO / Silo object and console ports | ## Verify native and compatibility authentication {#auth} Before enabling compatibility extensions, verify native login, account identity, and build version using the `psql` binary from your Mimus installation: ```sh 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](https://www.postgresql.org/docs/19/client-authentication.html) (`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. --- Backlinks: - [How-to Guides](/docs/guides/) - [DocumentDB and the gateway](/docs/mongo/architecture/) - [Base · PostgreSQL 19.0](/docs/reference/patches/base/) ================ Source: https://mimus.pgsty.com/docs/guides/backup-and-recovery/index.md ================ # 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. --- LLMS index: [llms.txt](/llms.txt) --- ## Run physical backups and offline page checks {#physical-backup} 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: ```sh /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 {#key-custody} 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](/docs/tde/recovery/) for full runbooks. ## Logical pg_restore for single-node DocumentDB {#documentdb-restore} 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 {#wal-limits} 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](/docs/mssql/temporary-storage/). --- Backlinks: - [How-to Guides](/docs/guides/) ================ Source: https://mimus.pgsty.com/docs/guides/extensions/index.md ================ # 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. --- LLMS index: [llms.txt](/llms.txt) --- ## Choosing extension binaries {#abi} 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: ```sh 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 {#application} 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](/docs/reference/verification/) for tested combinations. ## Storage and third-party extensions {#storage} 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](/docs/tde/tables/#coverage). --- Backlinks: - [Merging four PostgreSQL forks into one kernel](/blog/merging-four-postgresql-forks-into-one-kernel/) - [MySQL compatibility as a PostgreSQL 18 extension](/blog/mysql-as-a-postgresql-18-extension/) - [The kernel patches pg_tde needs and their upstream prospects](/blog/pg-tde-kernel-patches-and-upstream/) - [How-to Guides](/docs/guides/) - [DocumentDB and the gateway](/docs/mongo/architecture/) - [Enable TDE and encrypt a table](/docs/tde/tables/) - [Mimus 19.0.1 (r4 candidate)](/release/19.0.1/) ================ Source: https://mimus.pgsty.com/docs/guides/failover-and-conflicts/index.md ================ # Conflict resolution and standby failover > Choose deterministic conflict rules for bidirectional Spock replication, monitor apply workers, and rehearse standby promotion. --- LLMS index: [llms.txt](/llms.txt) --- ## Choose conflict arbitration rules {#policies} 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](/docs/spock/upstream/snowflake/) extension. ## Monitor subscriptions and conflict logs {#monitoring} Check subscription state, replication slot lag, and recorded conflict history on every writable node: ```sql 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](/docs/spock/operations/) for detailed diagnostics. ## Rehearse physical standby promotion {#failover} 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](/docs/spock/recovery/). --- Backlinks: - [How-to Guides](/docs/guides/) ================ Source: https://mimus.pgsty.com/docs/concepts/index.md ================ # Concepts & Architecture > Why Mimus unifies session wire hooks, stateless service gateways, encryption, replication and extensions on one PostgreSQL 19.0 kernel. --- LLMS index: [llms.txt](/llms.txt) --- Mimus starts from a simple premise: instead of operating separate data silos for relational, MySQL, MSSQL, document, key-value, coordination and object workloads, let every client protocol read and write one PostgreSQL 19.0 storage engine. ## Three layers of design {#three-layers} - **Wire protocols** decide how clients connect: session protocols (`PostgreSQL :5432`, `MySQL :3306`, `MSSQL :1433`) attach directly to backend processes via thin kernel hooks, while high-concurrency service protocols (`MongoDB :27017`, `Redis :6379`, `etcd :2379`, `S3 :9000`) enter through stateless multiplexing gateways. - **Dialects** decide what clients speak once connected: PostgreSQL SQL, MySQL SQL (`pg_mysql`), T-SQL (`Babelfish`), BSON queries (`DocumentDB`), and Oracle compatibility helpers (`orafce`) load as extensions. - **Engine capabilities** protect, replicate and enrich shared MVCC tables: transparent relation and WAL encryption ([PG TDE](/docs/tde/)), active-active logical replication ([pgEdge](/docs/spock/)), spatial indexing (`PostGIS`), vector search (`pgvector`, `VectorChord`), and native PostgreSQL 19 `REPACK`. Continue below for the detailed connection path and deployment boundaries. --- Section pages: - [Unified kernel, protocol hooks and gateways](/docs/concepts/architecture/): How session wire hooks and stateless service gateways converge on PostgreSQL 19.0 tables, encryption and replication. - [Isolation rules, feature locks and exclusions](/docs/concepts/boundaries/): Why Mimus isolates one compatibility protocol per instance, guards cluster startup with mimus_required_features, and excludes conflicting forks. ================ Source: https://mimus.pgsty.com/docs/concepts/architecture/index.md ================ # Unified kernel, protocol hooks and gateways > How session wire hooks and stateless service gateways converge on PostgreSQL 19.0 tables, encryption and replication. --- LLMS index: [llms.txt](/llms.txt) --- ## Two classes of wire protocols {#protocol-classes} PostgreSQL runs one backend process per client connection. Mimus therefore separates wire protocols into two classes so only stateful database sessions touch the kernel: | Dimension | Session database protocols | Service API protocols | | --- | --- | --- | | Protocols | PostgreSQL (`5432`), MySQL (`3306`), MSSQL (`1433`) | MongoDB (`27017`), Redis (`6379`), etcd (`2379`), S3 (`9000`) | | Connection shape | Stateful session: transactions, session GUCs, temp tables, SQL dialect | Thousands of pooled requests, long-lived watches, HTTP/gRPC/RESP streams | | Entry path | Postmaster hands the socket to a backend process driven by an extension hook | Stateless external gateway multiplexes client sockets onto a small SQL pool | | Kernel patches | Yes: OpenHalo protocol hook (`300`/`301`) and Babelfish TDS/T-SQL (`400`/`401`) | None required: data models and transactional semantics live in SQL/C extensions | ## From connection to physical table {#connections} ![Mimus 19.0.1 kernel stack: native PostgreSQL 5432 and one session compatibility listener over nine PostgreSQL 19.0 patch layers with PG TDE and pgEdge Spock](/images/arch-en-light.svg) {.mimus-diagram .only-light} ![Mimus 19.0.1 kernel stack: native PostgreSQL 5432 and one session compatibility listener over nine PostgreSQL 19.0 patch layers with PG TDE and pgEdge Spock](/images/arch-en-dark.svg) {.mimus-diagram .only-dark} Every Mimus instance accepts native PostgreSQL connections on port `5432`. Adding `pg_mysql` opens MySQL wire connections; adding `babelfishpg_tds` and its companion T-SQL extensions opens MSSQL TDS connections. Each compatibility listener maps logical databases onto PostgreSQL schemas so administrators can inspect physical tables, roles, indexes and backups directly from `psql`. Choose **at most one** compatibility protocol per instance (`MySQL`, `MSSQL`, or `MongoDB`). All databases inside one `PGDATA` directory share server processes and `shared_preload_libraries`. Workloads needing both MySQL and MSSQL run on two separate instances. ## Single-node MongoDB gateway {#documentdb} In `19.0.1-r4` acceptance on Debian 13 amd64, Mimus verified single-node DocumentDB 1.2 paired with its standalone MongoDB wire gateway (`27017`). MongoDB drivers connect to the gateway while BSON documents live inside PostgreSQL tables managed via `5432`. Both logical restore strategies—excluding `cron` via `pg_restore -N cron`, or pausing `pg_cron`, replacing default jobs in one transaction, and restoring full job history—returned all 63 documents under the original collection name in PyMongo checks. ## Storage, replication and extensions {#extensions} `pg_tde` encrypts relation pages, indexes, TOAST tables and WAL locally on disk; `spock` replicates logical row changes across writable nodes; extensions such as `PostGIS`, `pgvector`, `VectorChord`, `orafce` and `pg_cron` operate on the same catalog and storage engine. When combining encrypted storage with bidirectional replication, configure a key provider and create encrypted relations on each node independently. See the [Kernel Patch Manifest](/docs/reference/patches/) for layer-by-layer patch boundaries. --- Backlinks: - [One kernel, many protocols](/blog/one-kernel-many-protocols/) - [Architecture](/docs/etcd/architecture/) - [MongoDB](/docs/mongo/) - [DocumentDB and the gateway](/docs/mongo/architecture/) - [Compatibility](/docs/mongo/compatibility/) - [Try it with Pigsty](/docs/mongo/quickstart/) - [Migration and operations](/docs/mssql/operations/) - [MySQL](/docs/mysql/) - [Architecture](/docs/redis/architecture/) - [Base · PostgreSQL 19.0](/docs/reference/patches/base/) - [Verification Matrix](/docs/reference/verification/) - [Architecture](/docs/s3/architecture/) - [Mimus 19.0.1 (r4 candidate)](/release/19.0.1/) ================ Source: https://mimus.pgsty.com/docs/concepts/boundaries/index.md ================ # Isolation rules, feature locks and exclusions > Why Mimus isolates one compatibility protocol per instance, guards cluster startup with mimus_required_features, and excludes conflicting forks. --- LLMS index: [llms.txt](/llms.txt) --- ## One compatibility listener per instance {#isolation} Although a Mimus binary built through patch layer `401` contains the kernel hooks for both OpenHalo (`MySQL`) and Babelfish (`MSSQL`), each running `PGDATA` cluster enables **at most one** compatibility protocol alongside native PostgreSQL (`5432`). - `shared_preload_libraries`, background workers, parser hooks, and custom GUC namespaces apply across the entire PostgreSQL instance. - Isolating one compatibility listener per instance keeps parser dispatch, catalog resolution, connection limits, and failover runbooks predictable. Note that this rule is a product support boundary rather than a hard startup error. ## Data-directory feature locks {#feature-lock} A plain community PostgreSQL 19.0 data directory can start on Mimus, and an unused Mimus directory with `mimus_required_features = ''` can be handed back to stock PostgreSQL 19.0 (verified across 36/36 handoff checks in `19.0.1-r4`). Once an instance activates transparent encryption (`tde`), MySQL catalog objects, Babelfish catalogs, or Spock conflict metadata, Patch `000` records that dependency persistently for the cluster. On subsequent startups or WAL recovery, Mimus verifies that the required preload modules and hooks are present before opening relations or replaying records—preventing silent corruption or unreadable ciphertext errors mid-query. ## Hard exclusions and out-of-scope forks {#out-of-scope} To preserve storage reliability and crash safety, several upstream PostgreSQL forks and extensions are explicitly excluded from Mimus: | Project | Reason for exclusion | Recommended alternative | | --- | --- | --- | | **Citus** | Incompatible with Percona's `pg_tde` kernel storage hooks even when `pg_tde` is disabled; DocumentDB's distributed Citus module is likewise excluded | Run Citus on a dedicated stock PostgreSQL cluster | | **TimescaleDB** | Conflicts with `pg_tde` kernel storage paths regardless of whether encryption is enabled | Run TimescaleDB on a dedicated stock PostgreSQL cluster | | **OrioleDB** | Alters table and index access method signatures across the storage engine | Use separate OrioleDB builds outside Mimus | | **IvorySQL / Oracle wire** | Oracle's TNS wire protocol has no open-source implementation, and IvorySQL modifies core system catalogs | Use the `orafce` extension for Oracle SQL functions and packages | | **External `pg_repack`** | Rewrites `tde_heap` relations into unencrypted `heap` pages without error | Use PostgreSQL 19's built-in **`REPACK`** command | ================ Source: https://mimus.pgsty.com/docs/reference/index.md ================ # Reference > Authoritative lookup tables for Mimus wire protocols, server parameters, 19.0.1-r4 verification results, and the nine kernel patch layers. --- LLMS index: [llms.txt](/llms.txt) --- Consult these technical reference pages for exact protocol ports, preload profiles, GUC settings, product acceptance data, and patch-series source identities. - [Protocol, port and capability matrix](/docs/reference/matrix/) — Side-by-side summary of all eight wire protocols, core engine capabilities, licenses, and integration maturity. - [Preload profiles and server parameters](/docs/reference/configuration/) — Consolidated `shared_preload_libraries` combinations and key `mimus`, `mysql`, `babelfish`, `pg_tde`, and `spock` GUC settings. - [19.0.1-r4 verification and test matrix](/docs/reference/verification/) — Debian 13 amd64 acceptance counts, 12 tested combinations, upstream regression baselines, and OCI digests. - [Kernel patch manifest (000–401)](/docs/reference/patches/) — Exact build order, upstream baselines, Git trees, and adaptation scope for `patch/series.json`. {.cards} --- Section pages: - [Protocol, port and capability matrix](/docs/reference/matrix/): Complete lookup table of wire protocols, ports, gateways, storage and replication extensions, licenses, and integration status. - [Preload profiles and server parameters](/docs/reference/configuration/): Reference table of shared_preload_libraries profiles and core GUC parameters for Mimus, MySQL, MSSQL, PG TDE and pgEdge. - [19.0.1-r4 verification and test matrix](/docs/reference/verification/): Product acceptance on Debian 13 amd64, upstream test results and release status as of 6 December 2026. - [Kernel Patch Manifest (000–401)](/docs/reference/patches/): Code-level manifest of the nine cumulative PostgreSQL 19.0 patch layers and matched extension trees in patch/series.json. ================ Source: https://mimus.pgsty.com/docs/reference/matrix/index.md ================ # Protocol, port and capability matrix > Complete lookup table of wire protocols, ports, gateways, storage and replication extensions, licenses, and integration status. --- LLMS index: [llms.txt](/llms.txt) --- ## Wire protocols {#protocols} | Protocol | Default port | Entry class | Implementation | Kernel layer | Status | | --- | ---: | --- | --- | --- | --- | | PostgreSQL | `5432` | Session (native) | Native PostgreSQL 19.0 server | `000` | Verified (`19.0.1-r4`) | | [MySQL](/docs/mysql/) | `3306` | Session hook | OpenHalo protocol hook + `pg_mysql 1.0` | `300` / `301` | Verified (`19.0.1-r4` + public source) | | [MSSQL](/docs/mssql/) | `1433` | Session hook | Babelfish for PostgreSQL (`babelfishpg_*`) | `400` / `401` | Verified (`19.0.1-r4`) | | [MongoDB](/docs/mongo/) | `27017` | Service gateway | Single-node `DocumentDB 1.2` + gateway | None | Verified single-node (`19.0.1-r4`) | | [Redis](/docs/redis/) | `6379` | Service gateway | `pgredis` Go gateway + `pg_redis` extension | None | Release candidate (`v0.1.0-rc1` on PG 18) | | [etcd](/docs/etcd/) | `2379` | Service gateway | `pgetcd` gRPC gateway + `pg_etcd` extension | None | Release candidate (`v0.1.0-rc2` on PG 18) | | [S3](/docs/s3/) | `9000` | Service gateway | `pgsilo` backend on Silo (`silo_api` SQL) | None | MVP in progress | | [Kafka](/docs/kafka/) | `9092` | Service gateway | — | — | Design exploration | {.wide} ## Engine capabilities and extensions {#capabilities} | Capability | Component | Kernel layer | License | Summary | | --- | --- | --- | --- | --- | | [Transparent Data Encryption](/docs/tde/) | Percona `pg_tde 2.3` | `100` / `101` | PostgreSQL-style | Encrypts `tde_heap` tables, indexes, TOAST, and optional cluster WAL via file, Vault, or KMIP keys | | [Multi-Master Replication](/docs/spock/) | pgEdge `Spock 5.0.15` | `200` / `201` | PostgreSQL License | Asynchronous active-active logical replication with `last_update_wins`, `delta_apply`, `LOLOR`, and `Snowflake` | | Spatial, Vector & Rust Extensions | `PostGIS`, `pgvector`, `VectorChord`, `pgrx 0.20.1`, `orafce` | Header fixes in `401` | Various open source | Build against `/usr/mimus-19/bin/pg_config`; `Citus`, `TimescaleDB`, `OrioleDB`, and external `pg_repack` are excluded | {.wide} ## Status definitions {#status-terms} - **Verified (`19.0.1-r4`)**: Exercised in the Debian 13 amd64 product acceptance suite on PostgreSQL 19.0; see [19.0.1-r4 Verification](/docs/reference/verification/). - **Release candidate**: A versioned release candidate of the standalone gateway + extension project exists and was verified on PostgreSQL 18, pending public packaging. - **MVP in progress**: Core object and SQL schemas run in active development toward an initial experimental release inside [Silo](https://silo.pgsty.com/). - **Design exploration**: Documented architectural questions only, with no committed design or implementation schedule. --- Backlinks: - [Reference](/docs/reference/) ================ Source: https://mimus.pgsty.com/docs/reference/configuration/index.md ================ # Preload profiles and server parameters > Reference table of shared_preload_libraries profiles and core GUC parameters for Mimus, MySQL, MSSQL, PG TDE and pgEdge. --- LLMS index: [llms.txt](/llms.txt) --- ## Preload combinations {#preload} Select one client profile per `PGDATA` directory and combine it optionally with `pg_tde` and `spock`. All 12 combinations below passed preload and installation-order acceptance (`97/97` orders) in `19.0.1-r4`: | Profile | `shared_preload_libraries` examples | | --- | --- | | Native PostgreSQL | `''`, `'pg_tde'`, `'spock'`, `'pg_tde, spock'` | | PostgreSQL + MySQL | `'pg_mysql'`, `'pg_tde, pg_mysql'`, `'pg_mysql, spock'`, `'pg_tde, pg_mysql, spock'` | | PostgreSQL + MSSQL | `'babelfishpg_tds'`, `'pg_tde, babelfishpg_tds'`, `'babelfishpg_tds, spock'`, `'pg_tde, babelfishpg_tds, spock'` | ## Core cluster parameters {#core-gucs} | Parameter | Context | Purpose | | --- | --- | --- | | `mimus_required_features` | Read-only (`SHOW`) | Lists cluster-level features (`tde`, compatibility catalogs, replication metadata) recorded in `PGDATA` and enforced at startup | | `default_table_access_method` | User / DB / System | Set to `tde_heap` to make newly created tables encrypted by default inside a database or session | | `wal_level` | Postmaster | Must be `logical` when using `spock` bidirectional replication | | `track_commit_timestamp` | Postmaster | Must be `on` on every node participating in `spock` conflict resolution | | `output_plugin_libraries` | Postmaster | Include `'pgoutput,spock_output'` on PostgreSQL 19 nodes running `spock` | ## Wire-protocol parameters {#protocol-gucs} | Parameter | Component | Default | Purpose | | --- | --- | --- | --- | | `mysql.listener_on` | `pg_mysql` | `on` | Controls whether the MySQL wire protocol listener starts when `pg_mysql` is preloaded | | `mysql.port` | `pg_mysql` | `3306` | TCP port bound by the MySQL protocol listener | | `mysql.database` | `pg_mysql` | `'postgres'` | Host PostgreSQL database whose schemas map to MySQL logical databases | | `babelfishpg_tds.listen_addresses` | `Babelfish` | `'*'` | Network interfaces bound by the TDS listener | | `babelfishpg_tds.port` | `Babelfish` | `1433` | TCP port bound by the TDS listener | | `babelfishpg_tsql.database_name` | `Babelfish` | `'babelfish_db'` | PostgreSQL database hosting Babelfish logical databases and schemas | | `babelfishpg_tsql.migration_mode` | `Babelfish` | `'single-db'` | Logical database mapping mode (`single-db` or `multi-db`) | {.wide} ## Encryption and replication parameters {#engine-gucs} | Parameter | Component | Purpose | | --- | --- | --- | | `pg_tde.wal_encrypt` | `pg_tde` | Enables cluster-wide WAL encryption after configuring a global key provider (requires restart) | | `pg_tde.enforce_encryption` | `pg_tde` | Rejects creating unencrypted tables when encryption enforcement is required | | `spock.conflict_resolution` | `spock` | Node policy for row conflicts (such as `last_update_wins`, `first_update_wins`, `keep_local`, or `error`) | | `spock.enable_ddl_replication` | `spock` | Controls automatic DDL propagation for replicated objects | For component-specific settings, see [MySQL configuration](/docs/mysql/reference/), [PG TDE manual](/docs/tde/), and [pgEdge manual](/docs/spock/). --- Backlinks: - [Reference](/docs/reference/) ================ Source: https://mimus.pgsty.com/docs/reference/verification/index.md ================ # 19.0.1-r4 verification and test matrix > Product acceptance on Debian 13 amd64, upstream test results and release status as of 6 December 2026. --- LLMS index: [llms.txt](/llms.txt) --- ## What was verified {#verified} The `19.0.1-r4` candidate passed product acceptance on **Debian 13 amd64** on 5 December 2026. [Candidate image identity](#image) · [Frozen source revisions](/docs/reference/patches/base/#version) | Scope | Result | | --- | --- | | Debian 13 amd64 candidate image | 31/31 product checks, 97/97 preload and installation orders across 12 supported combinations, and 7/7 Spock checks. The release precheck passed with zero waivers. | | Kernel and backup | All 245 core tests passed on ordinary heap and again on forced `tde_heap`. All 12 physical backups across the candidate and assertion builds passed independent restore and offline page checks. | | Native kernel | `check-world` passed on Debian 13 amd64 and Ubuntu 26.04 amd64 and arm64. All 36 plain data-directory handoff checks passed. Ubuntu coverage applies to the frozen kernel. | ## Which combinations were exercised? {#profiles} The 12 configurations combine three client choices with four storage and replication choices. Each cell was tested across its distinct preload and SQL extension installation orders. The native PostgreSQL connection remains available in every configuration. | Client configuration | Storage and replication choices exercised | Orders passed | | --- | --- | ---: | | Native PostgreSQL only | Neither extension, PG TDE, Spock, both | 7/7 | | PostgreSQL + MySQL | Neither extension, PG TDE, Spock, both | 45/45 | | PostgreSQL + TDS (MSSQL) | Neither extension, PG TDE, Spock, both | 45/45 | The single-node MongoDB gateway had separate logical restore checks. [DocumentDB restore scope](/docs/concepts/architecture/#documentdb) ## Upstream regression results {#upstream} Four upstream suites returned nonzero exit codes. The failures match the reviewed baselines. | Upstream suite | Exit code | Result | | --- | ---: | --- | | Percona global TDE `installcheck-world` | 2 | 622 SQL and isolation checks passed. TAP had 31 passing groups, 7 failures and 2 with no tests. Failures include ordinary-tool expectations and operations refused on encrypted sources. | | pg_tde Meson | 4 | 39 passed, 4 failed, 3 skipped. Two tests lacked Perl dependencies, one differed in Unicode alignment and one expected a physical upgrade of an encrypted cluster. | | pg_tde Meson with live key services | 1 | 43 passed, 1 failed, 2 skipped. The remaining test expected a physical upgrade that Mimus refuses. | | Spock SQL | 2 | 32/34 passed. `matview` and `autoddl` differed in the order of `DROP CASCADE` notices. The separate TAP run passed 30 groups with 663 assertions, with one PG17-only group skipped. | ## Earlier builds {#earlier} Earlier validation on Rocky Linux 10.3 x86-64 with GCC 14.3.1 built and exercised all nine cumulative patches. The four-component tree passed 245 core tests before the pgrx header fix. With that fix, pgrx 0.20.1 passed 790 PG19 tests with 3 upstream-default skips. The earlier two-node study exercised bidirectional MySQL/TDS writes on an encrypted table, subscriber catch-up, conflict resolution and point-in-time recovery with plaintext and encrypted WAL. An earlier Ubuntu arm64 candidate passed core regression in six configurations before Spock integration. ## Candidate image identity {#image} These digests identify the Debian 13 image used in acceptance. To compare a published image with the candidate, resolve the `linux/amd64` manifest and read its `config.digest`. | OCI object | Tested SHA-256 digest | | --- | --- | | Image index | `sha256:db9e09fa1c9294f406a53964a6b57c2543f5277743b54b15f509a5448447deae` | | Platform manifest | `sha256:0c7c251ae65d5ca3e298d11de32085358e6b7e5c0c2418161af5b7bd6667db61` | | Platform config | `sha256:11ddd23673aaeaa39dc80f11988c0e4ed3c2493bbb6625a0cf5d64a8e727c79f` | ## Choosing this revision {#release} As of 6 December 2026 the public kernel and `pg_mysql` repositories contain the tested revisions. You can build both from source. The formal Git tag and publication of the verified image are pending. [19.0.1 availability](/release/19.0.1/#availability) · [Source build tutorial](/docs/tutorials/build-and-run/#build) Citus and TimescaleDB are outside the supported configuration, including when `pg_tde` is disabled. With encrypted WAL, r4 excludes cascading physical replication and a restarted standby receiving WAL again from the start of a segment. Rehearse recovery with the keys, software and backup chain you will deploy. [Backup and recovery](/docs/tde/recovery/) · [pgEdge failover boundaries](/docs/spock/recovery/) --- Backlinks: - [Blog](/blog/) - [Merging four PostgreSQL forks into one kernel](/blog/merging-four-postgresql-forks-into-one-kernel/) - [One kernel, many protocols](/blog/one-kernel-many-protocols/) - [Extensions & Workloads](/docs/guides/extensions/) - [MSSQL](/docs/mssql/) - [Reference](/docs/reference/) - [Protocol & Capability Matrix](/docs/reference/matrix/) - [Base · PostgreSQL 19.0](/docs/reference/patches/base/) - [400 / 401 · MSSQL](/docs/reference/patches/mssql/) - [Mimus 19.0.1 (r4 candidate)](/release/19.0.1/) ================ Source: https://mimus.pgsty.com/docs/reference/patches/index.md ================ # Kernel Patch Manifest (000–401) > Code-level manifest of the nine cumulative PostgreSQL 19.0 patch layers and matched extension trees in patch/series.json. --- LLMS index: [llms.txt](/llms.txt) --- This reference catalogs the exact nine kernel patch layers (`000` through `401`) recorded in `patch/series.json`. Start at [Base · PostgreSQL 19.0](/docs/reference/patches/base/) for the community commit, cluster feature locks, and matched extension source trees, then inspect each upstream-and-adaptation pair (`100`/`101`, `200`/`201`, `300`/`301`, `400`/`401`) in build order. --- Section pages: - [Base · PostgreSQL 19.0](/docs/reference/patches/base/): Identify the community base, the Mimus revision and the directory requirements recorded by patch 000. - [100 / 101 · Percona TDE](/docs/reference/patches/tde/): Storage and WAL interfaces, startup checks and the matching backup client. - [200 / 201 · pgEdge](/docs/reference/patches/spock/): Preserve old column values and commit metadata for conflict resolution and replay. - [300 / 301 · MySQL](/docs/reference/patches/mysql/): How the OpenHalo connection hooks and pg_mysql share the PostgreSQL backend. - [400 / 401 · MSSQL (Babelfish)](/docs/reference/patches/mssql/): Babelfish parser and executor changes, the PostgreSQL 19.0 port and TDS integration. --- Backlinks: - [Kernel, Hooks & Gateways](/docs/concepts/architecture/) - [Reference](/docs/reference/) ================ Source: https://mimus.pgsty.com/docs/reference/patches/base/index.md ================ # Base · PostgreSQL 19.0 > Identify the community base, the Mimus revision and the directory requirements recorded by patch 000. --- LLMS index: [llms.txt](/llms.txt) --- ## Version identity {#version} 19.0.1 means community PostgreSQL **19.0** (`REL_19_0`, `5c839a2a08b9`) plus **Mimus revision 1**. In `19.0.1-r4`, the final patch commit `7af97b6707f5` and the integration commit `0d8a551aa121` in `pgsty/mimus` have the same tree, `07fbb73680de`. The candidate was built from that tree. Some programs in this build, including `pg_dump --version`, report PostgreSQL 19.0. Keep the build revision and the extension builds with the backup inventory. [PostgreSQL 19 manual](https://www.postgresql.org/docs/19/) ## What 000 shares {#requirements} Patch 000 adds common code to record features on first use and check requirements when the server starts. Later pairs supply the feature-specific checks. Read `SHOW mimus_required_features` on a running server. An unused cluster starts with an empty list. A cluster that installed an extension can still need its recovery support after application sessions disconnect. Preserve the recorded requirements and provision the matching recovery software. No extension is needed for native PostgreSQL connections. Start here to [connect with psql](/docs/guides/instance-planning/#auth) or check the [tested platforms](/docs/reference/verification/). ## Match the extension sources {#components} The r4 freeze records the nine kernel layers and the extension inputs in `patch/series.json` (format 8, patch repository commit `4089ead024de`). The kernel layers are `000`, `100`, `101`, `200`, `201`, `300`, `301`, `400` and `401`, in that order. The standard installation prefix is `/usr/mimus-19`. Build each extension with that installation’s `bin/pg_config` and headers. The SQL extension version alone cannot identify a local adaptation. For a MySQL installation, the `mimus/` checkout already contains the integrated kernel. The sibling `pg_mysql/` checkout supplies the complete extension. [Build from the two source repositories](/docs/mysql/quickstart/#build) | Component | Source to build | Resulting Git tree | | --- | --- | --- | | [pg_tde](/docs/tde/) | `pg_tde/` at `5424c937188c` plus `ext-pg-tde-` patches `000`, `002`, `007`, `008`, `009`, `010` in manifest order | `c62d1e2dceae` | | [pgEdge (Spock)](/docs/spock/) | `spock/` at 5.0.15, frozen commit `e710faa6fe21126d898fa660e9b6dc8ed0da9438` | `8da352a31c41` | | [pg_mysql](/docs/mysql/quickstart/) | `pg_mysql/` at `1e631f9802c5` | `53dd9be3e87b` | | [Babelfish extensions](/docs/mssql/install/) | `babelfish/babelfish_extensions/` at `99c35f5ebb80` plus `ext-babelfish-` patches `001`, `004`, `010`, `011`, `012`, `013`, `014` | `891436a7f948` | The single-node DocumentDB build starts from `documentdb-1.2-0.tar.gz` (SHA-256 `72069b5b0b48d571dd01b2e9ff587fc56e66762c7ecefecc76e9a7335e46dd6e`). The candidate applies `ext-documentdb-001-extension-config-dump.patch` so a logical archive includes the collection metadata. Its separate gateway is version 1.2.0. [Gateway and restore scope](/docs/concepts/architecture/#documentdb) For pg_tde, prepare the indicated extension sources with `subprojects/libkmip` at `1bf36d7ecdb8`, then run `meson setup build -Dpg_config=/usr/mimus-19/bin/pg_config` and `meson install -C build` in the extension directory. For Spock, put the matching bin directory first in PATH and run `make PG_CONFIG=/usr/mimus-19/bin/pg_config` followed by `make PG_CONFIG=/usr/mimus-19/bin/pg_config install`. Run the install step with write access to the target prefix. --- Backlinks: - [Merging four PostgreSQL forks into one kernel](/blog/merging-four-postgresql-forks-into-one-kernel/) - [MySQL compatibility as a PostgreSQL 18 extension](/blog/mysql-as-a-postgresql-18-extension/) - [The kernel patches pg_tde needs and their upstream prospects](/blog/pg-tde-kernel-patches-and-upstream/) - [MSSQL](/docs/mssql/) - [Install and initialize](/docs/mssql/install/) - [Kernel Patches](/docs/reference/patches/) - [400 / 401 · MSSQL](/docs/reference/patches/mssql/) - [Verification Matrix](/docs/reference/verification/) - [PG TDE](/docs/tde/) - [Debian / Ubuntu](/docs/tde/upstream/apt/) - [Supported versions](/docs/tde/upstream/index/supported-versions/) - [Get started](/docs/tde/upstream/install/) - [Load the extension](/docs/tde/upstream/setup/) - [RHEL / Rocky / Alma](/docs/tde/upstream/yum/) - [Build & Start Mimus](/docs/tutorials/build-and-run/) - [Mimus 19.0.1 (r4 candidate)](/release/19.0.1/) ================ Source: https://mimus.pgsty.com/docs/reference/patches/tde/index.md ================ # 100 / 101 · Percona TDE > Storage and WAL interfaces, startup checks and the matching backup client. --- LLMS index: [llms.txt](/llms.txt) --- ## Percona storage changes {#storage} 100 imports selected changes from Percona’s PostgreSQL 19 tree, including its TOAST fix. A pluggable storage manager, relation-file identity during rewrites, asynchronous I/O callbacks and WAL segment I/O hooks give `pg_tde` a place to encrypt and decrypt pages. The extension supplies `tde_heap`, key management and the WAL implementation. [Percona PostgreSQL](https://github.com/percona/postgres) ## Integration and compatibility {#add-only} 101 integrates callback registration and checks that the TDE storage, WAL and recovery methods are ready before replay on a marked directory. The matching backup client checks whether the source requires TDE-aware WAL handling. Using an older plain client can bypass this check. The paired `pg_tde_waldump` also identifies Spock’s subtransaction commit-time record in encrypted WAL. These interfaces affect extension builds even if every application table uses ordinary heap storage. To choose which objects to encrypt and which backup tool to use, follow the [PG TDE manual](/docs/tde/). ## Index DDL on encrypted tables {#index-ddl} In r4, `ext-pg-tde-002-index-encryption.patch` changes the DDL event handler in the pg_tde extension. A B-tree index reports `btree` in `pg_am`. The extension checks the index file’s encryption state during `ALTER INDEX`, including the internal operation that records the original name of a TDS index. Acceptance covered enforcement both on and off. Encrypted indexes stayed encrypted after a `fillfactor` change, a tablespace move and `REINDEX`. Enforcement continued to reject parameter changes to a plaintext index. Existing indexes retain their own storage state. Check indexes moved with an older build individually by OID. [Verify indexes and TOAST](/docs/mssql/encrypted-tables/#verify) · [Candidate build manifest](/docs/reference/patches/mssql/#tde-increments) ## WAL and online backup {#wal-backup} Kernel layer 100 and pg_tde extension patch `009` carry the WAL key-switch fix. Layer 101 exposes the backup page-verification callback. Extension patch `010` decrypts a copy of the page for checksum verification and fixes temporary-key cleanup. Recovery still depends on the historical keys and their mappings. [Restore and verify a backup](/docs/tde/recovery/) --- Backlinks: - [The kernel patches pg_tde needs and their upstream prospects](/blog/pg-tde-kernel-patches-and-upstream/) - [400 / 401 · MSSQL](/docs/reference/patches/mssql/) - [PG TDE](/docs/tde/) ================ Source: https://mimus.pgsty.com/docs/reference/patches/spock/index.md ================ # 200 / 201 · pgEdge > Preserve old column values and commit metadata for conflict resolution and replay. --- LLMS index: [llms.txt](/llms.txt) --- ## Upstream replication support {#upstream} 200 imports PG19 patches 015, 025, 030, 035 and 090 from Spock 5.0.15. The apply worker can use a column’s previous value to merge concurrent increments. When a conflicting local row wins but its numeric value must still change, the worker can write a new row version and preserve the original timestamp and origin. Upstream patch 030 added a separate `CommitTs/SUBTRANS_TS` WAL record (`0x20`) for this history. [Spock PG19 patches](https://github.com/pgEdge/spock/tree/v5.0.15/patches/19) ## Recovery support {#replay} 201 records the cluster requirement when `CREATE EXTENSION spock` succeeds. In r4, 201 writes the surviving subtransaction timestamp and origin overrides in the same WAL record as the transaction’s `COMMIT`. The matching kernel replays them even on a recovery instance without logical workers. Archives containing the earlier `0x20` record require their original recovery environment. Preloading the extension on the writable nodes enables replication. Before activating it, upgrade every physical standby and PITR environment that may have to replay a new record. Use `pg_waldump` for plaintext WAL or the paired `pg_tde_waldump` and keys for encrypted WAL. For node setup, conflict handling and rollback decisions, see the [pgEdge manual](/docs/spock/). --- Backlinks: - [pgEdge](/docs/spock/) - [Recovery, failover and rollback](/docs/spock/recovery/) ================ Source: https://mimus.pgsty.com/docs/reference/patches/mysql/index.md ================ # 300 / 301 · MySQL > How the OpenHalo connection hooks and pg_mysql share the PostgreSQL backend. --- LLMS index: [llms.txt](/llms.txt) --- 300 imports the server-side changes selected from OpenHalo v19.0.0. Its protocol hooks let a preloaded module register a listener and drive the client handshake and command loop in a PostgreSQL backend. `pg_mysql` supplies the MySQL protocol and dialect. The native listener continues to speak PostgreSQL. [OpenHalo](https://github.com/pgsty/openhalo) 301 adapts protocol registration, type coercion, collation and foreign-key handling, and the server defaults. It checks for the registered MySQL callbacks on a cluster that depends on them. Use the matching `pg_mysql` build when starting or restoring that cluster. An application migration should exercise its actual driver and column types. Deploy a separate instance if TDS access is also required. For application access and compatibility, see the [MySQL manual](/docs/mysql/). --- Backlinks: - [MySQL compatibility as a PostgreSQL 18 extension](/blog/mysql-as-a-postgresql-18-extension/) - [The kernel patches pg_tde needs and their upstream prospects](/blog/pg-tde-kernel-patches-and-upstream/) - [MySQL](/docs/mysql/) - [Protocol, dialect and origins](/docs/mysql/architecture/) - [Limits and troubleshooting](/docs/mysql/status/) ================ Source: https://mimus.pgsty.com/docs/reference/patches/mssql/index.md ================ # 400 / 401 · MSSQL (Babelfish) > Babelfish parser and executor changes, the PostgreSQL 19.0 port and TDS integration. --- LLMS index: [llms.txt](/llms.txt) --- 400 imports native Babelfish changes selected against its PG19 beta base. They give the Babelfish extensions access to parser, executor, catalog, session and error-reporting paths needed for T-SQL. `babelfishpg_tds` handles the wire connection. `babelfishpg_tsql`, `babelfishpg_common` and `babelfishpg_money` provide the language and supporting types. [Babelfish for PostgreSQL](https://babelfishpg.org/) 401 completes the port to the 19.0 release. It reconciles listener and parser changes with OpenHalo, adds startup checks for dependent clusters and connects the Babelfish dump helpers to the Meson build. Use the complete pair to build the dump utilities. When migrating a database, verify SQL Server object naming, temporary tables and dump/restore on the chosen build. The cross-protocol row test covered a table defined on both nodes. For connecting a TDS client and assessing T-SQL compatibility, see the [MSSQL manual](/docs/mssql/). The current 401 also scopes a temporary union inside `pg_bswap128()` so that pgrx can generate Rust bindings from the installed PG19 headers. Regenerate bindings against the target Mimus SDK. ## Babelfish and pg_tde in r4 {#tde-increments} The r4 kernel ends at layer 401, which now includes the temporary-relation reference fix originally tested as layer 402. The paired extensions supply the T-SQL checks and storage behavior below. The example SQL can be used from a TDS deployment connection. [r4 kernel and extension trees](/docs/reference/patches/base/#components) | Change | Delivered in | What users see | | --- | --- | --- | | 1 · Table encryption option | Babelfish extension `001` | `CREATE TABLE … WITH (ENCRYPTION=ON/OFF)` fails before creating a table, preventing accidental delivery of a plaintext table as encrypted. | | 2 · Index DDL on encrypted tables | pg_tde extension `002` | TDS can add an index with enforcement on. An encrypted index stays encrypted after PG changes its parameters, moves its tablespace or rebuilds it. [Index patch](/docs/reference/patches/tde/#index-ddl) | | 3 · Per-table selection | SQL example in the image | A dedicated TDS transaction creates the table and verifies its storage, two indexes, TOAST table and TOAST index before committing. [Deploy and verify](/docs/mssql/encrypted-tables/#per-table) | | 4 · Temporary relation cleanup | Babelfish extension `004` and kernel `401` | Statements and cursors release their own references. A cursor can finish reading a temporary relation after a procedure returns, with cleanup governed by the transaction outcome. | The earlier component build (`a3b80a5a99a1`) exercised these four changes, including reads and updates of seven existing permanent tables after restart. r4 also fixes temporary-key cleanup in pg_tde `010` and passed all 45 preload and installation orders involving TDS. T-SQL temporary objects using ordinary heap and query spill files can contain plaintext. [Temporary storage](/docs/mssql/temporary-storage/) · [r4 coverage](/docs/reference/verification/#profiles) Babelfish patches `010–013` cover UTF-16 byte length for `nvarchar` and selected `CONVERT` styles for floats, binary values and dates. Patch `014` installs the synonym and stop-word files used by full-text search. [Application compatibility](/docs/mssql/compatibility/#clients) --- Backlinks: - [Create encrypted permanent tables over TDS](/docs/mssql/encrypted-tables/) - [Known limits and troubleshooting](/docs/mssql/status/) - [Temporary tables, table variables and plaintext on disk](/docs/mssql/temporary-storage/) - [100 / 101 · Percona TDE](/docs/reference/patches/tde/) ================ Source: https://mimus.pgsty.com/docs/tde/index.md ================ # PG TDE > Encrypt selected tables with pg_tde 2.3 and plan for recovery with the original keys. --- LLMS index: [llms.txt](/llms.txt) --- Use PG TDE when a copy of a selected PostgreSQL relation on disk must be unreadable without its principal key. PostgreSQL decrypts pages as it reads them, so authorized SQL users continue to see the data. Plan for two separate assets from the outset: a physical backup and access to all keys required to read it. 1. [Enable the extension and verify a table](/docs/tde/tables/) in a new database. 2. [Choose a key provider and decide whether to encrypt WAL](/docs/tde/keys/). WAL encryption covers the whole cluster. 3. [Restore a backup into a separate instance](/docs/tde/recovery/) before relying on it. For SQL Server clients, configure the key in the physical PG database and create and use the tables in the TDS logical database. [Create encrypted tables over TDS](/docs/mssql/encrypted-tables/) · [T-SQL temporary objects and plaintext on disk](/docs/mssql/temporary-storage/) Mimus pairs Percona’s `pg_tde` 2.3 with its PG19 kernel and tools. Installing the extension in a database registers a cluster-wide recovery requirement. The [100 / 101 patch pair](/docs/reference/patches/tde/) describes what the kernel checks. [Percona documentation](https://docs.percona.com/pg-tde/) ## Percona pg_tde 2.3.0 manual {#upstream} The [full upstream manual](/docs/tde/upstream/) covers [what is encrypted](/docs/tde/upstream/index/tde-encrypts/), [key providers](/docs/tde/upstream/global-key-provider-configuration/), [SQL functions](/docs/tde/upstream/functions/), [settings](/docs/tde/upstream/variables/) and [command-line tools](/docs/tde/upstream/command-line-tools/). The upstream release is 2.3.0. Mimus uses SQL extension version `2.3` plus the [paired source changes](/docs/reference/patches/base/#components). For an existing Mimus data directory, follow the [Mimus recovery and migration procedure](/docs/tde/recovery/). --- Section pages: - [Enable TDE and encrypt a table](/docs/tde/tables/): Configure preload, create a database key and check the table and its primary key. - [Keys and WAL encryption](/docs/tde/keys/): Separate database keys from the server key and preserve old key versions for recovery. - [Back up, restore and migrate](/docs/tde/recovery/): Choose the streaming client by WAL history, verify an independent restore and plan a major upgrade. - [Percona pg_tde 2.3.0 upstream manuals](/docs/tde/upstream/): The complete pg_tde documentation, organized from first principles through installation, operations, and reference. --- Backlinks: - [Concepts](/docs/concepts/) - [Migration and operations](/docs/mssql/operations/) - [Migration and recovery](/docs/mysql/operations/) - [Parameters & Preload](/docs/reference/configuration/) - [Protocol & Capability Matrix](/docs/reference/matrix/) - [Base · PostgreSQL 19.0](/docs/reference/patches/base/) - [100 / 101 · Percona TDE](/docs/reference/patches/tde/) - [Percona pg_tde 2.3.0](/docs/tde/upstream/) - [Technical reference](/docs/tde/upstream/advanced-topics/) - [Reference overview](/docs/tde/upstream/advanced-topics/tech-reference/) - [Usage reference](/docs/tde/upstream/advanced-topics/usage-guide/) - [Architecture](/docs/tde/upstream/architecture/) - [Encryption architecture](/docs/tde/upstream/architecture/encryption-architecture/) - [Keys and providers](/docs/tde/upstream/architecture/key-provider-management/) - [Architecture overview](/docs/tde/upstream/architecture/overview/) - [Blog](/docs/tde/upstream/blog/) - [Guides](/docs/tde/upstream/blog/guide/) - [How pg_tde keeps data encrypted through PostgreSQL storage](/docs/tde/upstream/blog/guide/encryption-architecture/) - [A production checklist for pg_tde](/docs/tde/upstream/blog/guide/production-checklist/) - [From the Percona blog](/docs/tde/upstream/blog/percona/) - [An early look at pg_tde](/docs/tde/upstream/blog/percona/early-project-update/) - [The road to the pg_tde release candidate](/docs/tde/upstream/blog/percona/rc-announcement/) - [Questions from the PostgreSQL TDE webinar](/docs/tde/upstream/blog/percona/webinar-qa/) - [Release notes](/docs/tde/upstream/blog/release/) - [pg_tde 2.2.1: PostgreSQL 16 support and safer rewind](/docs/tde/upstream/blog/release/2.2.1/) - [pg_tde 2.2.2: Vault Enterprise KMIP and faster WAL encryption](/docs/tde/upstream/blog/release/2.2.2/) - [Command-line tools](/docs/tde/upstream/command-line-tools/) - [Tool overview](/docs/tde/upstream/command-line-tools/cli-tools/) - [Archive WAL](/docs/tde/upstream/command-line-tools/pg-tde-archive-decrypt/) - [Change key provider](/docs/tde/upstream/command-line-tools/pg-tde-change-key-provider/) - [Checksums](/docs/tde/upstream/command-line-tools/pg-tde-checksums/) - [Restore WAL](/docs/tde/upstream/command-line-tools/pg-tde-restore-encrypt/) - [WAL inspection](/docs/tde/upstream/command-line-tools/pg-tde-waldump/) - [Contribute and get help](/docs/tde/upstream/contribute/) - [FAQ](/docs/tde/upstream/faq/) - [Features](/docs/tde/upstream/features/) - [SQL functions](/docs/tde/upstream/functions/) - [Get help](/docs/tde/upstream/get-help/) - [Key management](/docs/tde/upstream/global-key-provider-configuration/) - [Local keyring](/docs/tde/upstream/global-key-provider-configuration/keyring/) - [Akeyless](/docs/tde/upstream/global-key-provider-configuration/kmip-akeyless/) - [Fortanix DSM](/docs/tde/upstream/global-key-provider-configuration/kmip-fortanix/) - [KMIP setup](/docs/tde/upstream/global-key-provider-configuration/kmip-server/) - [Thales CipherTrust](/docs/tde/upstream/global-key-provider-configuration/kmip-thales/) - [OpenBao](/docs/tde/upstream/global-key-provider-configuration/openbao/) - [Choose a provider](/docs/tde/upstream/global-key-provider-configuration/overview/) - [Default principal key](/docs/tde/upstream/global-key-provider-configuration/set-principal-key/) - [HashiCorp Vault](/docs/tde/upstream/global-key-provider-configuration/vault/) - [Operations](/docs/tde/upstream/how-to/) - [Remove encryption from an encrypted table](/docs/tde/upstream/how-to/decrypt/) - [Encryption enforcement](/docs/tde/upstream/how-to/enforcement/) - [Configure multi-tenancy](/docs/tde/upstream/how-to/multi-tenant-setup/) - [Overview](/docs/tde/upstream/index/) - [What is TDE?](/docs/tde/upstream/index/about-tde/) - [How it works](/docs/tde/upstream/index/how-does-tde-work/) - [Why TDE?](/docs/tde/upstream/index/how-tde-helps/) - [Table access methods](/docs/tde/upstream/index/table-access-method/) - [Encrypted data](/docs/tde/upstream/index/tde-encrypts/) - [Limitations](/docs/tde/upstream/index/tde-limitations/) - [Operational impact](/docs/tde/upstream/index/what-tde-impacts/) - [Upstream legal notice](/docs/tde/upstream/legal-notice/) - [Introduction](/docs/tde/upstream/overview/) - [Release notes](/docs/tde/upstream/release-notes/) - [Alpha 1](/docs/tde/upstream/release-notes/alpha1/) - [Beta](/docs/tde/upstream/release-notes/beta/) - [Beta 2](/docs/tde/upstream/release-notes/beta2/) - [MVP](/docs/tde/upstream/release-notes/mvp/) - [RC 1](/docs/tde/upstream/release-notes/rc/) - [RC 2](/docs/tde/upstream/release-notes/rc2/) - [Upstream release index](/docs/tde/upstream/release-notes/release-notes/) - [1.0.0](/docs/tde/upstream/release-notes/release-notes-v1.0/) - [2.0.0](/docs/tde/upstream/release-notes/release-notes-v2.0/) - [2.1.0](/docs/tde/upstream/release-notes/release-notes-v2.1/) - [2.1.1](/docs/tde/upstream/release-notes/release-notes-v2.1.1/) - [2.1.2](/docs/tde/upstream/release-notes/release-notes-v2.1.2/) - [2.2.0](/docs/tde/upstream/release-notes/release-notes-v2.2.0/) - [2.2.1](/docs/tde/upstream/release-notes/release-notes-v2.2.1/) - [2.2.2](/docs/tde/upstream/release-notes/release-notes-v2.2.2/) - [pg_tde 2.3.0 (2026-11-17)](/docs/tde/upstream/release-notes/release-notes-v2.3.0/) - [Streaming replication](/docs/tde/upstream/replication/) - [About](/docs/tde/upstream/site/) - [Attribution and copyright](/docs/tde/upstream/site/attribution/) - [Documentation errata](/docs/tde/upstream/site/errata/) - [Verify encryption](/docs/tde/upstream/test/) - [GUC settings](/docs/tde/upstream/variables/) - [WAL encryption](/docs/tde/upstream/wal-encryption/) - [Encrypt First Table](/docs/tutorials/encrypt-first-table/) ================ Source: https://mimus.pgsty.com/docs/tde/tables/index.md ================ # Enable TDE and encrypt a table > Configure preload, create a database key and check the table and its primary key. --- LLMS index: [llms.txt](/llms.txt) --- ## Prepare a new database {#enable} Use a matching Mimus 19.0.1 installation containing the `pg_tde` library, extension SQL and control file. On a new test cluster add `pg_tde` to `shared_preload_libraries` in `postgresql.conf`, retaining other required libraries. Restart with the matching server. Connect with `psql` as an administrator to the database in which you will create the table. For this exercise, create a directory outside `PGDATA` named `/var/lib/mimus-keys` on the server, owned by the database service account with mode 0700. Use a fresh file name. The server will manage the keyring. File providers are suitable for local exercises; anyone who takes the backup and the readable keyring can recover the data. ## Create and verify {#table} ```sql CREATE EXTENSION pg_tde WITH SCHEMA public; SELECT pg_tde_add_database_key_provider_file( 'lab_provider', '/var/lib/mimus-keys/lab.per'); SELECT pg_tde_create_key_using_database_key_provider('lab_key', 'lab_provider'); SELECT pg_tde_set_key_using_database_key_provider('lab_key', 'lab_provider'); CREATE TABLE public.ledger ( id integer PRIMARY KEY, balance integer NOT NULL ) USING tde_heap; INSERT INTO public.ledger VALUES (1, 100); SELECT id, balance FROM public.ledger; SELECT pg_tde_is_encrypted('public.ledger'::regclass) AS table_encrypted, pg_tde_is_encrypted('public.ledger_pkey'::regclass) AS index_encrypted; SHOW mimus_required_features; ``` Expect row `(1,100)`, two true values, and `tde` in the feature list. To convert an existing heap table use `ALTER TABLE ... SET ACCESS METHOD tde_heap` after configuring its database key. This rewrites storage. Allow for the table lock, disk space and backup window. ## Which objects are protected? {#coverage} The encrypted table’s data, indexes and out-of-line TOAST values are covered. For a partitioned table, check each physical partition that stores rows. Native PG `CREATE TEMP TABLE` can use `tde_heap`. Babelfish table variables, `#` tables and temporary `SELECT INTO` use `heap` with enforcement off for the runtime login. [T-SQL temporary objects and plaintext on disk](/docs/mssql/temporary-storage/) System catalogs, statistics, object names and query spill files remain readable. A normal heap table stays plaintext. Logical exports return readable data, so protect their storage and transport separately. Enable WAL encryption separately if WAL must also be protected. [Key and WAL configuration](/docs/tde/keys/) To reorganize an encrypted table on Mimus, use native PostgreSQL 19 `REPACK` and verify the resulting table, index and TOAST storage. The external pg_repack extension is unsupported. [Storage compatibility](/docs/guides/extensions/#storage) --- Backlinks: - [Extensions & Workloads](/docs/guides/extensions/) - [Create encrypted permanent tables over TDS](/docs/mssql/encrypted-tables/) - [PG TDE](/docs/tde/) - [Keys and WAL encryption](/docs/tde/keys/) - [Back up, restore and migrate](/docs/tde/recovery/) ================ Source: https://mimus.pgsty.com/docs/tde/keys/index.md ================ # Keys and WAL encryption > Separate database keys from the server key and preserve old key versions for recovery. --- LLMS index: [llms.txt](/llms.txt) --- ## Where the keys live {#providers} Relation keys are stored wrapped in the data directory. A database principal key from its provider unwraps them. The provider can be database-scoped or global. In the [file example](/docs/tde/tables/) the provider lives outside the data directory. For a deployment, choose a supported KMS such as Vault or KMIP and test its reachability and authentication from every intended recovery host. Record provider identity, key names and versions. Keep credentials, certificates and file keyrings recoverable independently of the database host. [Percona key management](/docs/tde/upstream/global-key-provider-configuration/) ## Encrypt the WAL stream {#wal} WAL encryption applies to all databases, including ordinary heap tables. Establish the restore procedure on every backup and standby host before enabling it. On the test cluster, with the key directory from the previous page, configure a dedicated server principal key: ```sql SELECT pg_tde_add_global_key_provider_file( 'wal_provider', '/var/lib/mimus-keys/wal.per'); SELECT pg_tde_create_key_using_global_key_provider('server_key', 'wal_provider'); SELECT pg_tde_set_server_key_using_global_key_provider('server_key', 'wal_provider'); SELECT pg_tde_verify_server_key(); SELECT key_name, provider_name FROM pg_tde_server_key_info(); ALTER SYSTEM SET pg_tde.wal_encrypt = on; ``` Restart the server and run `SHOW pg_tde.wal_encrypt`. Expect `on`. Earlier WAL and backups retain their original requirements. Turning the switch off leaves historical encrypted segments in the recovery chain. For continuous archiving use Percona’s `pg_tde_archive_decrypt` and `pg_tde_restore_encrypt` as documented for the chosen archive system. Protect the decrypted archive independently. ## Rotation {#rotation} Schedule rotation outside all backup jobs. Retain every principal/server key version needed from the oldest retained backup through its recovery targets. After rotation, take a fresh full backup and restore it on another host. A new key with the old name cannot decrypt data wrapped with the lost key. [Backup and recovery](/docs/tde/recovery/) --- Backlinks: - [Create encrypted permanent tables over TDS](/docs/mssql/encrypted-tables/) - [PG TDE](/docs/tde/) - [Enable TDE and encrypt a table](/docs/tde/tables/) - [Encrypt First Table](/docs/tutorials/encrypt-first-table/) ================ Source: https://mimus.pgsty.com/docs/tde/recovery/index.md ================ # Back up, restore and migrate > Choose the streaming client by WAL history, verify an independent restore and plan a major upgrade. --- LLMS index: [llms.txt](/llms.txt) --- ## Choose the physical backup path {#backup} Use the binaries paired with the source revision. Set `PGHOST`, `PGPORT` and `PGUSER` for a replication-authorized connection. Choose a new `BACKUP` path on protected storage. Use data checksums on the source, keep the default online page verification enabled and suspend key rotation until the backup finishes. These examples assume the default tablespace layout. With encrypted WAL, r4 excludes cascading physical replication and a restarted standby receiving WAL again from the start of a segment. **Only relations encrypted, WAL always plaintext.** With no server WAL key history, the paired ordinary client can stream a plain-format backup: ```sh pg_basebackup -D "$BACKUP" -Fp -X stream ``` **Encrypted WAL or a source referred to the TDE client.** The current switch alone is insufficient if WAL keys were configured previously. For the local example, run the following with read access to the source `PGDATA`. On a separate backup host securely stage the same `pg_tde` metadata from the source. Supply the configured provider files, credentials and historical keys there so the server key can be opened. The file provider in the example uses an absolute path; make that path available to the backup and restore accounts. For providers with relative paths, retain their locations relative to the target. Use the plain directory format with streamed WAL: ```sh mkdir -m 700 "$BACKUP" cp -Rp "$PGDATA/pg_tde" "$BACKUP/pg_tde" pg_tde_basebackup -D "$BACKUP" -E -Fp -X stream ``` ## Read the backup independently {#restore} Before starting a restored copy, verify the backup manifest and all its WAL ranges with the matching reader and keys. Keep an independent inventory of the expected encrypted objects and mappings. Reject a backup with a missing mapping even if both online and manifest checks pass. 1. On an isolated host, make a working copy of the complete backup owned by the database service account. Keep the original backup intact. Supply the same-major Mimus server, matching preloads and the original provider material. For a file keyring, restore its protected copy separately. If external tablespaces were used, restore their files and mappings. 2. Set the restore host’s port and socket directory so your client can only reach the copy. Keep it isolated from replication peers and shared archive destinations. Start the copy with `pg_ctl -D "$RESTORE" -l "$RESTORE_LOG" -w start`. For PITR, provision the continuous WAL archive, restore command, recovery target and `recovery.signal` before the first start. 3. Connect explicitly to the restored database. For the [ledger example](/docs/tde/tables/), run the following. Expect the committed row `1,100`, encryption on table and index, and the `tde` requirement. For a real backup also compare an out-of-line value, row counts and application invariants with the backup-time baseline. ```sql SELECT id, balance FROM public.ledger ORDER BY id; SELECT pg_tde_is_encrypted('public.ledger'::regclass), pg_tde_is_encrypted('public.ledger_pkey'::regclass); SHOW mimus_required_features; ``` Compare the heap, indexes and TOAST storage with the saved encryption inventory. Shut down the restored copy cleanly and run `pg_tde_checksums --check -D "$RESTORE"`. Require exit code 0 and `Bad checksums` of 0. Installing `pg_tde` can create recovery dependencies before the first encrypted user table exists. An older backup may cross this activation point during replay. Equip the recovery host before replay and retain the original marker and key metadata. A missing historical key makes the affected backup unreadable even with intact relation files. ## Cross-major migration {#upgrade} Use logical dump and restore into a new cluster for a major upgrade. Prepare roles, the target extension and its own keys before loading encrypted objects. Review the dump’s extension entries, table access methods and ownership. Use the target major’s `pg_dump -Fc` and `pg_restore --exit-on-error`, then verify constraints, sequences, rows and encryption on the target. Protect the logical archive as plaintext. Keep the source until the checks pass. Physical `pg_upgrade` of a TDE-marked cluster is outside the 19.0.1 path. [Percona backup procedure](/docs/tde/upstream/how-to/backup-wal-enabled/) --- Backlinks: - [Backup & Recovery](/docs/guides/backup-and-recovery/) - [100 / 101 · Percona TDE](/docs/reference/patches/tde/) - [Verification Matrix](/docs/reference/verification/) - [Recovery, failover and rollback](/docs/spock/recovery/) - [PG TDE](/docs/tde/) - [Keys and WAL encryption](/docs/tde/keys/) - [Major upgrade](/docs/tde/upstream/command-line-tools/pg-tde-upgrade/) - [Backup with WAL encryption enabled](/docs/tde/upstream/how-to/backup-wal-enabled/) - [Restore encrypted backups](/docs/tde/upstream/how-to/restore-backups/) - [Uninstall pg_tde](/docs/tde/upstream/how-to/uninstall/) - [Upgrade pg_tde](/docs/tde/upstream/how-to/upgrade/) - [Mimus 19.0.1 (r4 candidate)](/release/19.0.1/) ================ Source: https://mimus.pgsty.com/docs/tde/upstream/index.md ================ # Percona pg_tde 2.3.0 upstream manuals > The complete pg_tde documentation, organized from first principles through installation, operations, and reference. --- LLMS index: [llms.txt](/llms.txt) --- > [!NOTE] Upstream Percona pg_tde 2.3.0 reference > For the paired Mimus build, backup verification tools and major upgrades, see [PG TDE on Mimus](/docs/tde/). The pg_tde documentation follows the path a production PostgreSQL deployment takes: understand the encryption model, install the extension, configure key custody, validate encrypted tables, then operate WAL, backups, recovery, and upgrades. The current release is [pg_tde 2.3.0](/docs/tde/upstream/release-notes/release-notes-v2.3.0/), adding PostgreSQL 19 support and pg_tde-aware WAL record inspection. The Chinese edition includes these reviewed incremental changes. - [Overview](/docs/tde/upstream/index/) — understand TDE, pg_tde, supported deployments, and limitations. - [Get started](/docs/tde/upstream/install/) — install the package and create the extension. - [Key management](/docs/tde/upstream/global-key-provider-configuration/) — configure KMS providers and principal keys. - [Technical reference](/docs/tde/upstream/advanced-topics/) — architecture, functions, GUC variables, and replication. - [Operations](/docs/tde/upstream/how-to/) — backup, restore, enforcement, multi-tenancy, and upgrades. - [Release notes](/docs/tde/upstream/release-notes/) — follow compatibility and change history. {.cards} [PG.CENTER edition](https://github.com/pgsty/doc.pg.center/blob/4410c32dc9186a22859008303f474b72a779f583/content/percona/_index.md) · [Upstream source](https://github.com/percona/pg_tde/tree/5dd7a9e4e3599d88546f5de67ff0f4ef3fe51a9a) --- Section pages: - [Overview](/docs/tde/upstream/index/): Understand transparent data encryption, pg_tde, supported deployments, and its limits. - [pg_tde documentation](/docs/tde/upstream/overview/): Explore pg_tde capabilities, its PostgreSQL integration, and the documentation paths. - [Features](/docs/tde/upstream/features/): An inventory of encryption capabilities, supported access methods, and PostgreSQL integration. - [Install pg_tde](/docs/tde/upstream/install/): Choose packages, containers, Kubernetes, or a source archive for your PostgreSQL deployment. - [Install pg_tde on Debian or Ubuntu](/docs/tde/upstream/apt/): Install the separate pg_tde package from Percona’s Debian and Ubuntu repositories. - [Install pg_tde on Red Hat Enterprise Linux and Derivatives](/docs/tde/upstream/yum/): Install the pg_tde RPM package on Red Hat Enterprise Linux and compatible distributions. - [Configure pg_tde](/docs/tde/upstream/setup/): Preload the library, restart PostgreSQL, and enable the extension in a database. - [Validate Encryption with pg_tde](/docs/tde/upstream/test/): Create or convert a table with tde_heap and verify its encryption status. - [Key management](/docs/tde/upstream/global-key-provider-configuration/): Configure keyring files and external key management systems. - [Architecture](/docs/tde/upstream/architecture/): Learn how pg_tde encrypts data, manages keys, and integrates with PostgreSQL. - [Operations](/docs/tde/upstream/how-to/): Operational procedures for backup, restore, upgrades, enforcement, and multi-tenancy. - [Configure WAL encryption](/docs/tde/upstream/wal-encryption/): Create and assign the server principal key, then enable encrypted WAL writes. - [Streaming replication with tde_heap](/docs/tde/upstream/replication/): Prepare keys, roles, and encrypted base backups for a physical streaming replica. - [Technical reference](/docs/tde/upstream/advanced-topics/): Architecture, usage reference, GUC variables, functions, and replication details. - [GUC Variables](/docs/tde/upstream/variables/): Reference for WAL encryption, enforcement, global providers, and cipher selection. - [Functions](/docs/tde/upstream/functions/): SQL reference for providers, principal keys, privileges, and encryption status. - [Command-line tools](/docs/tde/upstream/command-line-tools/): Reference pages for the pg_tde utilities used with encrypted data and WAL. - [Release notes](/docs/tde/upstream/release-notes/): Release history and upgrade information for pg_tde. - [FAQ](/docs/tde/upstream/faq/): Answers about encryption boundaries, recovery, key rotation, and PostgreSQL compatibility. - [Contributing Guide](/docs/tde/upstream/contribute/): Build, test, and contribute code or documentation to the upstream pg_tde project. - [Get Help from Percona](/docs/tde/upstream/get-help/): Find community discussions, issue reporting, and Percona support channels. - [Legal notice](/docs/tde/upstream/legal-notice/): The upstream AI chatbot notice, retained for reference; this site does not embed that service. - [About](/docs/tde/upstream/site/): Source, licence, and maintenance information for the pg_tde documentation site. - [Blog](/docs/tde/upstream/blog/): Release notes, architecture notes, and operational guidance for pg_tde. --- Backlinks: - [PG TDE](/docs/tde/) ================ Source: https://mimus.pgsty.com/docs/tde/upstream/index/index.md ================ # Overview > Understand transparent data encryption, pg_tde, supported deployments, and its limits. --- LLMS index: [llms.txt](/llms.txt) --- > This is the Percona pg_tde 2.3.0 manual. For the paired build, backup tools and major upgrades, see [PG TDE on Mimus](/docs/tde/). [PG.CENTER edition](https://github.com/pgsty/doc.pg.center/blob/4410c32dc9186a22859008303f474b72a779f583/content/percona/index/_index.md) · [Upstream source](https://github.com/percona/pg_tde/tree/5dd7a9e4e3599d88546f5de67ff0f4ef3fe51a9a) --- Section pages: - [About Transparent Data Encryption](/docs/tde/upstream/index/about-tde/): An introduction to transparent encryption of data stored on disk. - [How pg_tde works](/docs/tde/upstream/index/how-does-tde-work/): How pg_tde applies encryption within the PostgreSQL storage path. - [Benefits of pg_tde](/docs/tde/upstream/index/how-tde-helps/): Where database-level encryption complements other protections for stored data. - [Encrypted data scope](/docs/tde/upstream/index/tde-encrypts/): Identify encrypted data files, WAL, and the information that remains unencrypted. - [Table access methods and pg_tde](/docs/tde/upstream/index/table-access-method/): Use tde_heap explicitly or as the default access method for new tables. - [Impact of pg_tde on database operations](/docs/tde/upstream/index/what-tde-impacts/): What changes for applications, database operations, performance, and upgrades. - [Supported PostgreSQL deployments](/docs/tde/upstream/index/supported-versions/): Check supported PostgreSQL distributions and the status of each supported major version. - [Limitations of pg_tde](/docs/tde/upstream/index/tde-limitations/): Review unencrypted data, unsupported operations, and WAL tool compatibility. --- Backlinks: - [Percona pg_tde 2.3.0](/docs/tde/upstream/) ================ Source: https://mimus.pgsty.com/docs/tde/upstream/index/about-tde/index.md ================ # About Transparent Data Encryption > An introduction to transparent encryption of data stored on disk. --- LLMS index: [llms.txt](/llms.txt) --- > This is the Percona pg_tde 2.3.0 manual. For the paired build, backup tools and major upgrades, see [PG TDE on Mimus](/docs/tde/). Transparent Data Encryption (TDE) protects your data at rest by ensuring that even if the underlying storage is compromised, the data remains unreadable without the correct decryption keys. This is especially critical for environments handling sensitive, regulated, or high-value information. This process runs transparently in the background, with minimal impact on database operations. Use the links below to explore how `pg_tde` helps secure your PostgreSQL deployments: [Discover the benefits of pg_tde ](/docs/tde/upstream/index/how-tde-helps/) [Understand pg_tde limitations ](/docs/tde/upstream/index/tde-limitations/) [View the full feature list ](/docs/tde/upstream/features/) [Get started with installation ](/docs/tde/upstream/install/) [PG.CENTER edition](https://github.com/pgsty/doc.pg.center/blob/4410c32dc9186a22859008303f474b72a779f583/content/percona/index/about-tde.md) · [Upstream source](https://github.com/percona/pg_tde/blob/5dd7a9e4e3599d88546f5de67ff0f4ef3fe51a9a/documentation/docs/index/about-tde.md) --- Backlinks: - [Features](/docs/tde/upstream/features/) - [Alpha 1](/docs/tde/upstream/release-notes/alpha1/) - [Beta](/docs/tde/upstream/release-notes/beta/) - [Beta 2](/docs/tde/upstream/release-notes/beta2/) - [RC 1](/docs/tde/upstream/release-notes/rc/) - [RC 2](/docs/tde/upstream/release-notes/rc2/) - [1.0.0](/docs/tde/upstream/release-notes/release-notes-v1.0/) - [2.0.0](/docs/tde/upstream/release-notes/release-notes-v2.0/) - [2.1.0](/docs/tde/upstream/release-notes/release-notes-v2.1/) - [2.1.1](/docs/tde/upstream/release-notes/release-notes-v2.1.1/) - [2.1.2](/docs/tde/upstream/release-notes/release-notes-v2.1.2/) - [2.2.0](/docs/tde/upstream/release-notes/release-notes-v2.2.0/) - [2.2.1](/docs/tde/upstream/release-notes/release-notes-v2.2.1/) - [2.2.2](/docs/tde/upstream/release-notes/release-notes-v2.2.2/) - [pg_tde 2.3.0 (2026-11-17)](/docs/tde/upstream/release-notes/release-notes-v2.3.0/) ================ Source: https://mimus.pgsty.com/docs/tde/upstream/index/how-does-tde-work/index.md ================ # How pg_tde works > How pg_tde applies encryption within the PostgreSQL storage path. --- LLMS index: [llms.txt](/llms.txt) --- > This is the Percona pg_tde 2.3.0 manual. For the paired build, backup tools and major upgrades, see [PG TDE on Mimus](/docs/tde/). To encrypt the data, two types of keys are used: * **Internal encryption keys** to encrypt user data. They are stored internally, near the data that they encrypt. * The **principal key** to encrypt database keys. It is kept separately from the database keys and is managed externally in the key management store. > [!NOTE] > For more information on managing and storing principal keys externally, including supported key management systems and the local keyring option, see [Key management overview](/docs/tde/upstream/global-key-provider-configuration/overview/). The encryption process works as follows: ![image](/docs/tde/upstream/assets/images/tde-flow.png) When a user creates an encrypted table using `pg_tde`, a new random key is generated internally for that table and is encrypted using the AES-CBC cipher algorithm. This key is used to encrypt all data the user inserts in that table. Eventually the encrypted data gets stored in the underlying storage. The internal key itself is encrypted using the principal key. The principal key is stored externally in the key management store. Similarly when the user queries the encrypted table, the principal key is retrieved from the key store to decrypt the internal key. Then the same unique internal key for that table is used to decrypt the data, and unencrypted data gets returned to the user. So, effectively, every TDE table has a unique key, and each table key is encrypted using the principal key. [Understand the encrypted data scope ](/docs/tde/upstream/index/tde-encrypts/) [PG.CENTER edition](https://github.com/pgsty/doc.pg.center/blob/4410c32dc9186a22859008303f474b72a779f583/content/percona/index/how-does-tde-work.md) · [Upstream source](https://github.com/percona/pg_tde/blob/5dd7a9e4e3599d88546f5de67ff0f4ef3fe51a9a/documentation/docs/index/how-does-tde-work.md) --- Backlinks: - [Why TDE?](/docs/tde/upstream/index/how-tde-helps/) ================ Source: https://mimus.pgsty.com/docs/tde/upstream/index/how-tde-helps/index.md ================ # Benefits of pg_tde > Where database-level encryption complements other protections for stored data. --- LLMS index: [llms.txt](/llms.txt) --- > This is the Percona pg_tde 2.3.0 manual. For the paired build, backup tools and major upgrades, see [PG TDE on Mimus](/docs/tde/). The benefits of using `pg_tde` are outlined below for different users and organizations. ## Benefits for organizations {#benefits-for-organizations} * **Data safety:** Prevents unauthorized access to stored data, even if backup files or storage devices are stolen or leaked. * **Enterprise-ready Architecture:** Supports both single and multi-tenancy, giving flexibility for SaaS providers or internal multi-user systems. ## Benefits for DBAs and engineers {#benefits-for-dbas-and-engineers} * **Granular control:** Encrypt specific tables or databases instead of the entire system, reducing performance overhead. * **Operational simplicity:** Works transparently without requiring major application changes. * **Defense in depth:** Adds another layer of protection to existing controls like TLS (encryption in transit), access control, and role-based permissions. When combined with the external Key Management Systems (KMS), `pg_tde` enables centralized control, auditing, and rotation of encryption keys—critical for secure production environments. > [!NOTE] See also > > You can find more information on Transparent Data Encryption (TDE) in [this article](https://www.percona.com/blog/transparent-data-encryption-tde/). [Learn how pg_tde works ](/docs/tde/upstream/index/how-does-tde-work/) [PG.CENTER edition](https://github.com/pgsty/doc.pg.center/blob/4410c32dc9186a22859008303f474b72a779f583/content/percona/index/how-tde-helps.md) · [Upstream source](https://github.com/percona/pg_tde/blob/5dd7a9e4e3599d88546f5de67ff0f4ef3fe51a9a/documentation/docs/index/how-tde-helps.md) --- Backlinks: - [What is TDE?](/docs/tde/upstream/index/about-tde/) ================ Source: https://mimus.pgsty.com/docs/tde/upstream/index/tde-encrypts/index.md ================ # Encrypted data scope > Identify encrypted data files, WAL, and the information that remains unencrypted. --- LLMS index: [llms.txt](/llms.txt) --- > This is the Percona pg_tde 2.3.0 manual. For the paired build, backup tools and major upgrades, see [PG TDE on Mimus](/docs/tde/). `pg_tde` encrypts the following components: * **User data** in tables using the extension, including associated TOAST data. The table metadata (column names, data types, etc.) is not encrypted. * **Temporary tables** created during the query execution, for data tables created using the extension. * **Write-Ahead Log (WAL) data** for the entire database cluster. This includes WAL data in encrypted and non-encrypted tables. * **Indexes** on encrypted tables. [Check out the table access methods ](/docs/tde/upstream/index/table-access-method/) [PG.CENTER edition](https://github.com/pgsty/doc.pg.center/blob/4410c32dc9186a22859008303f474b72a779f583/content/percona/index/tde-encrypts.md) · [Upstream source](https://github.com/percona/pg_tde/blob/5dd7a9e4e3599d88546f5de67ff0f4ef3fe51a9a/documentation/docs/index/tde-encrypts.md) --- Backlinks: - [PG TDE](/docs/tde/) - [How it works](/docs/tde/upstream/index/how-does-tde-work/) ================ Source: https://mimus.pgsty.com/docs/tde/upstream/index/table-access-method/index.md ================ # Table access methods and pg_tde > Use tde_heap explicitly or as the default access method for new tables. --- LLMS index: [llms.txt](/llms.txt) --- > This is the Percona pg_tde 2.3.0 manual. For the paired build, backup tools and major upgrades, see [PG TDE on Mimus](/docs/tde/). A table access method is the way how PostgreSQL stores the data in a table. The default table access method is `heap`. PostgreSQL organizes data in a heap structure, meaning there is no particular order to the rows in the table. Each row is stored independently and identified by its unique row identifier (TID). ## How the heap access method works {#how-the-heap-access-method-works} **Insertion**: When a new row is inserted, PostgreSQL finds a free space in the tablespace and stores the row there. **Deletion**: When a row is deleted, PostgreSQL marks the space occupied by the row as free, but the data remains until it is overwritten by a new insertion. **Updates**: PostgreSQL handles updates by deleting the old row and inserting a new row with the updated values. ## Custom access method {#custom-access-method} Custom access methods allow you to implement and define your own way of organizing data in PostgreSQL. This is useful if the default table access method doesn't meet your needs. Custom access methods are typically available with PostgreSQL extensions. When you install an extension and enable it in PostgreSQL, a custom access method is created. An example of such an approach is the `tde_heap` access method. It is automatically created **only** for the databases where you [enabled the `pg_tde` extension](/docs/tde/upstream/setup/) and configured the key provider, enabling you to encrypt the data. To use a custom access method, specify the `USING` clause for the `CREATE TABLE` command: ```sql CREATE TABLE table_name ( column1 data_type, column2 data_type, ... ) USING tde_heap; ``` ### How tde_heap works with pg_tde {#how-tdeheap-works-with-pgtde} The `tde_heap` access method works on top of the default `heap` access method and is a marker to point which tables require encryption. It uses the custom storage manager TDE SMGR, which becomes active only after you installed the `pg_tde` extension. Every data modification operation is first sent to the Buffer Manager, which updates the buffer cache. Then, it is passed to the storage manager, which then writes it to disk. When a table requires encryption, the data is sent to the TDE storage manager, where it is encrypted before written to disk. Similarly, when a client queries the database, the PostgreSQL core sends the request to the Buffer Manager which checks if the requested data is already in the buffer cache. If it’s not there, the Buffer Manager requests the data from the storage manager. The TDE storage manager reads the encrypted data from disk, decrypts it and loads it to the buffer cache. The Buffer Manager sends the requested data to the PostgreSQL core and then to the client. Thus, the encryption is done at the storage manager level. ## Changing the default table access method {#changing-the-default-table-access-method} You can change the default table access method so that every table in the entire database cluster is created using the custom access method. For example, you can enable data encryption by default by defining the `tde_heap` as the default table access method. However, consider the following before making this change: * This is a global setting and applies across the entire database cluster and not just a single database. We recommend setting it with caution because all tables and materialized views created without an explicit access method in their `CREATE` statement will default to the specified table access method. * You must create the `pg_tde` extension and configure the key provider for all databases before you modify the configuration. Otherwise PostgreSQL won't find the specified access method and will throw an error. Here is how you can set the new default table access method: 1. Add the access method to the `default_table_access_method` parameter: **via the \`ALTER SYSTEM\` command** Use `ALTER SYSTEM`, it requires superuser or `ALTER SYSTEM` privileges. ```sql ALTER SYSTEM SET default_table_access_method = tde_heap; ``` **via the configuration file** Edit the `postgresql.conf` configuration file and add the value for the `default_table_access_method` parameter. ```ini default_table_access_method = 'tde_heap' ``` **via the \`SET\` command** You can use the SET command to change the default table access method temporarily, for the current session. Unlike modifying the `postgresql.conf` file or using the `ALTER SYSTEM` command, the changes you make via the `SET` command don't persist after the session ends. You also don't need to have the superuser privileges to run the `SET` command. You can run the SET command anytime during the session. ```sql SET default_table_access_method = tde_heap; ``` 2. Reload the configuration to apply the changes: ```sql SELECT pg_reload_conf(); ``` [Understand pg_tde's limitations ](/docs/tde/upstream/index/tde-limitations/) [PG.CENTER edition](https://github.com/pgsty/doc.pg.center/blob/4410c32dc9186a22859008303f474b72a779f583/content/percona/index/table-access-method.md) · [Upstream source](https://github.com/percona/pg_tde/blob/5dd7a9e4e3599d88546f5de67ff0f4ef3fe51a9a/documentation/docs/index/table-access-method.md) --- Backlinks: - [FAQ](/docs/tde/upstream/faq/) - [Local keyring](/docs/tde/upstream/global-key-provider-configuration/keyring/) - [Encrypted data](/docs/tde/upstream/index/tde-encrypts/) - [Streaming replication](/docs/tde/upstream/replication/) - [Verify encryption](/docs/tde/upstream/test/) ================ Source: https://mimus.pgsty.com/docs/tde/upstream/index/what-tde-impacts/index.md ================ # Impact of pg_tde on database operations > What changes for applications, database operations, performance, and upgrades. --- LLMS index: [llms.txt](/llms.txt) --- > This is the Percona pg_tde 2.3.0 manual. For the paired build, backup tools and major upgrades, see [PG TDE on Mimus](/docs/tde/). This page summarizes how `pg_tde` interacts with core PostgreSQL operations. | Area | Affected | Notes / Actions | |------|-----------|-----------------| | **Backups** | ❌ Yes | Encrypted backups require `pg_tde`-aware tools. See [Backup with WAL encryption](/docs/tde/upstream/how-to/backup-wal-enabled/). | | **Restore** | ❌ Yes | Restored data remains encrypted; `pg_tde` transparently handles decryption. See [Restore encrypted backups](/docs/tde/upstream/how-to/restore-backups/). | | **Streaming replication** | ⚠️ Partial | Replicas must load the `pg_tde` shared library (shared_preload_libraries = 'pg_tde'). Without it, the replica will fail on operations involving `tde_heap`. | | **Logical replication** | ✅ No | Not affected. | | **Monitoring and statistics** | ✅ No | Not affected, including `pg_stat_monitor`. | | **Performance** | ⚠️ Slight | Minor CPU overhead due to enabling encryption, most noticeable on random write workloads. | [PG.CENTER edition](https://github.com/pgsty/doc.pg.center/blob/4410c32dc9186a22859008303f474b72a779f583/content/percona/index/what-tde-impacts.md) · [Upstream source](https://github.com/percona/pg_tde/blob/5dd7a9e4e3599d88546f5de67ff0f4ef3fe51a9a/documentation/docs/index/what-tde-impacts.md) --- Backlinks: - [2.1.0](/docs/tde/upstream/release-notes/release-notes-v2.1/) ================ Source: https://mimus.pgsty.com/docs/tde/upstream/index/supported-versions/index.md ================ # Supported PostgreSQL deployments > Check supported PostgreSQL distributions and the status of each supported major version. --- LLMS index: [llms.txt](/llms.txt) --- > The packages and support matrix below belong to Percona PostgreSQL. Build pg_tde against the matching Mimus installation before enabling it. [Mimus procedure](/docs/reference/patches/base/#components) The `pg_tde` extension is available for Percona Server for PostgreSQL [17.5](https://docs.percona.com/postgresql/17/) and later versions, an open source, drop-in replacement for PostgreSQL Community. These versions provide the `tde_heap` access method and offer full encryption capabilities, including encryption of tables, indexes and WAL data. For users who need `pg_tde` in PostgreSQL 16, a build is available as a [Tech Preview](https://docs.percona.com/postgresql/16/percona-ext.html#tech-preview-pg_tde-built-into-percona-server-for-postgresql-16). It is not officially supported, is not recommended for production, and does not follow the same release cadence as the supported PostgreSQL [17.5](https://docs.percona.com/postgresql/17/) and later versions. The extension is tightly integrated with Percona Server for PostgreSQL to deliver enhanced encryption functionality that is not available in community builds. ## Why choose Percona Server for PostgreSQL? {#why-choose-percona-server-for-postgresql} By using our PostgreSQL distribution, you get: - **Full encryption support** through the `tde_heap` access method, including tables, indexes and WAL data. - **Enhanced performance and enterprise-ready features** not available in community builds. - **Regular updates and security patches** backed by Percona’s expert support team. - **Professional support** and guidance for secure PostgreSQL deployments. > [!NOTE] > Support for earlier or limited versions of `pg_tde` (such as `tde_heap_basic`) has been deprecated. Still unsure which deployment fits your needs? [Contact our experts](https://www.percona.com/about/contact) to find the best solution for your environment. [Get started with installation ](/docs/tde/upstream/install/) [PG.CENTER edition](https://github.com/pgsty/doc.pg.center/blob/4410c32dc9186a22859008303f474b72a779f583/content/percona/index/supported-versions.md) · [Upstream source](https://github.com/percona/pg_tde/blob/5dd7a9e4e3599d88546f5de67ff0f4ef3fe51a9a/documentation/docs/index/supported-versions.md) --- Backlinks: - [An early look at pg_tde](/docs/tde/upstream/blog/percona/early-project-update/) - [The road to the pg_tde release candidate](/docs/tde/upstream/blog/percona/rc-announcement/) - [Questions from the PostgreSQL TDE webinar](/docs/tde/upstream/blog/percona/webinar-qa/) - [Limitations](/docs/tde/upstream/index/tde-limitations/) - [Alpha 1](/docs/tde/upstream/release-notes/alpha1/) - [Beta](/docs/tde/upstream/release-notes/beta/) - [Beta 2](/docs/tde/upstream/release-notes/beta2/) - [MVP](/docs/tde/upstream/release-notes/mvp/) - [RC 1](/docs/tde/upstream/release-notes/rc/) - [RC 2](/docs/tde/upstream/release-notes/rc2/) - [Upstream release index](/docs/tde/upstream/release-notes/release-notes/) - [1.0.0](/docs/tde/upstream/release-notes/release-notes-v1.0/) - [2.0.0](/docs/tde/upstream/release-notes/release-notes-v2.0/) - [2.1.0](/docs/tde/upstream/release-notes/release-notes-v2.1/) - [2.1.1](/docs/tde/upstream/release-notes/release-notes-v2.1.1/) - [2.1.2](/docs/tde/upstream/release-notes/release-notes-v2.1.2/) - [2.2.0](/docs/tde/upstream/release-notes/release-notes-v2.2.0/) - [2.2.1](/docs/tde/upstream/release-notes/release-notes-v2.2.1/) ================ Source: https://mimus.pgsty.com/docs/tde/upstream/index/tde-limitations/index.md ================ # Limitations of pg_tde > Review unencrypted data, unsupported operations, and WAL tool compatibility. --- LLMS index: [llms.txt](/llms.txt) --- > This is the Percona pg_tde 2.3.0 manual. For the paired build, backup tools and major upgrades, see [PG TDE on Mimus](/docs/tde/). ## Known incompatibilities in Percona Server for PostgreSQL {#known-incompatibilities-in-percona-server-for-postgresql} Some PostgreSQL extensions may not work with Percona Server for PostgreSQL due to internal changes required by `pg_tde`. These incompatibilities may occur even if `pg_tde` is not installed or enabled. ### Distributed and extension-based systems {#distributed-and-extension-based-systems} > [!WARNING] Citus and TimescaleDB are not supported > Percona Server for PostgreSQL is not compatible with distributed PostgreSQL extensions such as Citus or time-series extensions such as TimescaleDB. > > This limitation is caused by internal PostgreSQL changes related to `pg_tde` and is not dependent on enabling the extension. ## Limitations when using pg_tde {#limitations-when-using-pgtde} Limitations of `pg_tde` 2.3.0: * PostgreSQL’s internal system tables, which include statistics and metadata, are not encrypted. * Temporary files created when queries exceed `work_mem` are not encrypted. These files may persist during long-running queries or after a server crash which can expose sensitive data in plaintext on disk. ## Recovery without `pg_tde` in `shared_preload_libraries` {#recovery-without-pgtde-in-sharedpreloadlibraries} > [!DANGER] Risk of corruption when recovering encrypted clusters without pg_tde loaded > When recovering a PostgreSQL cluster that contains encrypted tables, the `pg_tde` extension must be loaded through the `shared_preload_libraries` configuration parameter. ## `ALTER DATABASE ... SET TABLESPACE` {#alter-database-set-tablespace} > [!WARNING] Changing a database tablespace has limited support with `pg_tde` > The `ALTER DATABASE ... SET TABLESPACE` command bypasses PostgreSQL's storage manager (SMGR), which `pg_tde` relies on to enforce encryption. > > - If encrypted objects exist in the database's default tablespace, the operation is refused. > - If no encrypted objects are present in the default tablespace, the operation is allowed. > > Only objects in the default tablespace are checked. Objects in other tablespaces are not evaluated by `pg_tde`. > > To move encrypted tables individually, use `ALTER TABLE ... SET TABLESPACE`, which operates through SMGR and is compatible with `pg_tde`. ## Currently unsupported WAL tools {#currently-unsupported-wal-tools} The following tools are currently unsupported with `pg_tde` WAL encryption: * `pg_createsubscriber` * `pg_receivewal` * `Barman` * `pg_verifybackup` by default fails with checksum or WAL key size mismatch errors. As a workaround, use `-s` (skip checksum) and `-n` (`--no-parse-wal`) to verify backups. * pgBackRest without `pg_tde_archive_decrypt` and `pg_tde_restore_encrypt`, or with `archive-async`, `archive-header-check`, or `checksum-page` enabled. ## Supported WAL tools {#supported-wal-tools} The following tools have been tested and verified by Percona to work with `pg_tde` WAL encryption: * Patroni, for an example configuration see the following [Patroni configuration file](#example-patroni-configuration) * `pg_tde_basebackup` (with `--wal-method=stream` or `--wal-method=none`), for details on using `pg_tde_basebackup` with WAL encryption, see [Backup with WAL encryption enabled](/docs/tde/upstream/how-to/backup-wal-enabled/) * `pg_tde_resetwal` * `pg_tde_rewind` * `pg_tde_upgrade` * `pg_tde_waldump` * pgBackRest, when `pg_tde_archive_decrypt` and `pg_tde_restore_encrypt` are configured and `archive-async`, `archive-header-check`, and `checksum-page` are disabled ## Example Patroni configuration {#example-patroni-configuration} The following is a Percona-tested example configuration. > [!DETAILS] Click to expand the Percona-tested Patroni configuration > ```yaml > # Example Patroni configuration file maintained by Percona > # Source: https://github.com/jobinau/pgscripts/blob/main/patroni/patroni.yml > scope: tde > name: pg1 > restapi: > listen: 0.0.0.0:8008 > connect_address: pg1:8008 > etcd3: > host: etcd1:2379 > bootstrap: > dcs: > ttl: 30 > loop_wait: 10 > retry_timeout: 10 > maximum_lag_on_failover: 1048576 > postgresql: > use_pg_rewind: true > use_slots: true > parameters: > archive_command: "/lib/postgresql/17/bin/pg_tde_archive_decrypt %f %p \"pgbackrest --stanza=tde archive-push %%p\"" > archive_timeout: 600s > archive_mode: "on" > logging_collector: "on" > restore_command: "/lib/postgresql/17/bin/pg_tde_restore_encrypt %f %p \"pgbackrest --stanza=tde archive-get %%f \\\"%%p\\\"\"" > pg_hba: > - local all all peer > - host all all 0.0.0.0/0 scram-sha-256 > - host all all ::/0 scram-sha-256 > - local replication all peer > - host replication all 0.0.0.0/0 scram-sha-256 > - host replication all ::/0 scram-sha-256 > initdb: > - encoding: UTF8 > - data-checksums > - set: shared_preload_libraries=pg_tde > post_init: /usr/local/bin/setup_cluster.sh > postgresql: > listen: 0.0.0.0:5432 > connect_address: pg1:5432 > data_dir: /var/lib/postgresql/patroni-17 > bin_dir: /lib/postgresql/17/bin > bin_name: > pg_basebackup: pg_tde_basebackup > pg_rewind: pg_tde_rewind > pgpass: /var/lib/postgresql/patronipass > authentication: > replication: > username: replicator > password: > superuser: > username: postgres > password: > parameters: > unix_socket_directories: /tmp > # Use unix_socket_directories: /var/run/postgresql for Debian/Ubuntu distributions > watchdog: > mode: off > tags: > nofailover: false > noloadbalance: false > clonefrom: false > nosync: false > ``` > [!WARNING] > The above example is Percona-tested, but Patroni versions differ, especially with discovery backends such as `etcd`. Ensure you adjust the configuration to match your environment, version, and security requirements. ## Next steps {#next-steps} Check which PostgreSQL versions and deployment types are compatible with `pg_tde` before planning your installation. [View the versions and supported deployments ](/docs/tde/upstream/index/supported-versions/) Begin the installation process when you're ready to set up encryption. [Start installing `pg_tde`](/docs/tde/upstream/install/) [PG.CENTER edition](https://github.com/pgsty/doc.pg.center/blob/4410c32dc9186a22859008303f474b72a779f583/content/percona/index/tde-limitations.md) · [Upstream source](https://github.com/percona/pg_tde/blob/5dd7a9e4e3599d88546f5de67ff0f4ef3fe51a9a/documentation/docs/index/tde-limitations.md) --- Backlinks: - [Temporary tables, table variables and plaintext on disk](/docs/mssql/temporary-storage/) - [How pg_tde keeps data encrypted through PostgreSQL storage](/docs/tde/upstream/blog/guide/encryption-architecture/) - [A production checklist for pg_tde](/docs/tde/upstream/blog/guide/production-checklist/) - [FAQ](/docs/tde/upstream/faq/) - [Choose a provider](/docs/tde/upstream/global-key-provider-configuration/overview/) - [Backup with WAL encryption enabled](/docs/tde/upstream/how-to/backup-wal-enabled/) - [What is TDE?](/docs/tde/upstream/index/about-tde/) - [Table access methods](/docs/tde/upstream/index/table-access-method/) - [Alpha 1](/docs/tde/upstream/release-notes/alpha1/) - [Beta](/docs/tde/upstream/release-notes/beta/) - [Beta 2](/docs/tde/upstream/release-notes/beta2/) - [MVP](/docs/tde/upstream/release-notes/mvp/) - [RC 1](/docs/tde/upstream/release-notes/rc/) - [RC 2](/docs/tde/upstream/release-notes/rc2/) - [Upstream release index](/docs/tde/upstream/release-notes/release-notes/) - [1.0.0](/docs/tde/upstream/release-notes/release-notes-v1.0/) - [2.0.0](/docs/tde/upstream/release-notes/release-notes-v2.0/) - [2.1.0](/docs/tde/upstream/release-notes/release-notes-v2.1/) - [2.1.1](/docs/tde/upstream/release-notes/release-notes-v2.1.1/) - [2.1.2](/docs/tde/upstream/release-notes/release-notes-v2.1.2/) - [2.2.0](/docs/tde/upstream/release-notes/release-notes-v2.2.0/) - [2.2.1](/docs/tde/upstream/release-notes/release-notes-v2.2.1/) - [Documentation errata](/docs/tde/upstream/site/errata/) - [WAL encryption](/docs/tde/upstream/wal-encryption/) ================ Source: https://mimus.pgsty.com/docs/tde/upstream/overview/index.md ================ # pg_tde documentation > Explore pg_tde capabilities, its PostgreSQL integration, and the documentation paths. --- LLMS index: [llms.txt](/llms.txt) --- > This is the Percona pg_tde 2.3.0 manual. For the paired build, backup tools and major upgrades, see [PG TDE on Mimus](/docs/tde/). Percona Transparent Data Encryption for PostgreSQL (`pg_tde`) is an open source, community driven and futureproof PostgreSQL extension that provides Transparent Data Encryption (TDE) to protect data at rest. `pg_tde` ensures that the data stored on disk is encrypted, and that no one can read it without the proper encryption keys, even if they gain access to the physical storage media. `pg_tde` is bundled as a component of Percona Server for PostgreSQL and requires its patches to function. It is packaged with Percona Distribution for PostgreSQL 17+ to ensure compatibility and proper operation. For more information, see the [Percona Distribution for PostgreSQL 18 documentation ](https://docs.percona.com/postgresql/18/). ### Installation guide {#installation-guide} Get started quickly with the step-by-step installation instructions. [How to install `pg_tde` ](/docs/tde/upstream/install/) ### :rocket: Features {#rocket-features} Explore what features Percona's `pg_tde` extension brings to PostgreSQL. [Check what you can do with `pg_tde` ](/docs/tde/upstream/features/) ### Architecture {#architecture} Understand how `pg_tde` integrates into PostgreSQL with Percona's architecture. Learn how keys are managed, how encryption is applied, and how our design ensures performance and security. [Check what’s under the hood for `pg_tde` ](/docs/tde/upstream/architecture/overview/) ### :loudspeaker: What's new? {#loudspeaker-what-s-new} Learn about the releases and changes in `pg_tde`. [Check what’s new in the latest version ](/docs/tde/upstream/release-notes/release-notes-v2.3.0/) [PG.CENTER edition](https://github.com/pgsty/doc.pg.center/blob/4410c32dc9186a22859008303f474b72a779f583/content/percona/overview.md) · [Upstream source](https://github.com/percona/pg_tde/blob/5dd7a9e4e3599d88546f5de67ff0f4ef3fe51a9a/documentation/docs/index.md) --- Backlinks: - [Attribution and copyright](/docs/tde/upstream/site/attribution/) ================ Source: https://mimus.pgsty.com/docs/tde/upstream/features/index.md ================ # Features > An inventory of encryption capabilities, supported access methods, and PostgreSQL integration. --- LLMS index: [llms.txt](/llms.txt) --- > This is the Percona pg_tde 2.3.0 manual. For the paired build, backup tools and major upgrades, see [PG TDE on Mimus](/docs/tde/). `pg_tde` is available for [Percona Server for PostgreSQL](https://docs.percona.com/postgresql/17/) The Percona Server for PostgreSQL provides an extended Storage Manager API that allows integration with custom storage managers. The following features are available for the extension: * [Table encryption](/docs/tde/upstream/test/#encrypt-data-in-a-new-table), including: * Data tables * Index data for encrypted tables * TOAST tables * Temporary tables > [!NOTE] > Metadata of those tables is not encrypted. * Single-tenancy support via a [global keyring provider](/docs/tde/upstream/global-key-provider-configuration/set-principal-key/) * [Multi-tenancy support](/docs/tde/upstream/how-to/multi-tenant-setup/) * Table-level granularity for encryption and access control * Multiple [Key management options](/docs/tde/upstream/global-key-provider-configuration/overview/) ## Next steps {#next-steps} Learn more about how `pg_tde` implements Transparent Data Encryption: [About Transparent Data Encryption ](/docs/tde/upstream/index/about-tde/) [PG.CENTER edition](https://github.com/pgsty/doc.pg.center/blob/4410c32dc9186a22859008303f474b72a779f583/content/percona/features.md) · [Upstream source](https://github.com/percona/pg_tde/blob/5dd7a9e4e3599d88546f5de67ff0f4ef3fe51a9a/documentation/docs/features.md) --- Backlinks: - [What is TDE?](/docs/tde/upstream/index/about-tde/) - [Introduction](/docs/tde/upstream/overview/) ================ Source: https://mimus.pgsty.com/docs/tde/upstream/install/index.md ================ # Install pg_tde > Choose packages, containers, Kubernetes, or a source archive for your PostgreSQL deployment. --- LLMS index: [llms.txt](/llms.txt) --- > The packages and support matrix below belong to Percona PostgreSQL. Build pg_tde against the matching Mimus installation before enabling it. [Mimus procedure](/docs/reference/patches/base/#components) You can select from multiple easy-to-follow installation options to install `pg_tde`, however **we strongly recommend using a Package Manager** for a convenient and quick installation. `pg_tde` availability by PostgreSQL version: | **PostgreSQL version** | **Is pg_tde installed automatically?** | **Action Required** | | -------- | -------- | -------- | | 17.x - 17.6 (minor updates) | Yes | None | | 17.7 (and later) | No | Install the package manually | | 18.x (and later) | No | Install the package manually | > [!IMPORTANT] > Starting with PPG 17.7, `pg_tde` is no longer bundled with the Percona server for PostgreSQL package. It is now delivered as a separate package named `percona-pg-tde(pg-version)` for Debian or Ubuntu and `percona-pg_tde(pg-version)` for Red Hat Enterprise Linux and Derivatives. > [!NOTE] > Specific information on the supported platforms, products, and versions is described in the [Percona Software and Platform Lifecycle ](https://www.percona.com/services/policies/percona-software-support-lifecycle) page. **Package manager** Percona provides installation packages in DEB and RPM formats for 64-bit Linux distributions. If you are on Debian or Ubuntu, use `apt` for installation. If you are on Red Hat Enterprise Linux or compatible derivatives, use `yum` for installation. [Install on Debian or Ubuntu ](/docs/tde/upstream/apt/) [Install on RHEL or derivatives ](/docs/tde/upstream/yum/) **Docker** `pg_tde` is a part of the Percona Distribution for PostgreSQL Docker image. Use this image to enjoy full encryption capabilities. Check below to get access to a detailed step-by-step guide. [Run in Docker ](https://docs.percona.com/postgresql/17/docker.html#enable-encryption) **Kubernetes** You can enable `pg_tde` when deploying Percona Server for PostgreSQL in Kubernetes using the Percona Operator. **Tar download \(not recommended\)** `pg_tde` is included in the Percona Distribution for PostgreSQL tarball. Select the below link to access the step-by-step guide. [Install from tarballs ](https://docs.percona.com/postgresql/18/tarball.html) ## Next steps {#next-steps} After finishing the installation, you can proceed with: [Set up pg_tde](/docs/tde/upstream/setup/) [Learn about key management](/docs/tde/upstream/global-key-provider-configuration/overview/) [Validate your encryption setup](/docs/tde/upstream/test/) [Enable WAL encryption](/docs/tde/upstream/wal-encryption/) [PG.CENTER edition](https://github.com/pgsty/doc.pg.center/blob/4410c32dc9186a22859008303f474b72a779f583/content/percona/install.md) · [Upstream source](https://github.com/percona/pg_tde/blob/5dd7a9e4e3599d88546f5de67ff0f4ef3fe51a9a/documentation/docs/install.md) --- Backlinks: - [Percona pg_tde 2.3.0](/docs/tde/upstream/) - [Usage reference](/docs/tde/upstream/advanced-topics/usage-guide/) - [A production checklist for pg_tde](/docs/tde/upstream/blog/guide/production-checklist/) - [What is TDE?](/docs/tde/upstream/index/about-tde/) - [Supported versions](/docs/tde/upstream/index/supported-versions/) - [Limitations](/docs/tde/upstream/index/tde-limitations/) - [Introduction](/docs/tde/upstream/overview/) - [Alpha 1](/docs/tde/upstream/release-notes/alpha1/) - [Beta](/docs/tde/upstream/release-notes/beta/) - [Beta 2](/docs/tde/upstream/release-notes/beta2/) - [RC 1](/docs/tde/upstream/release-notes/rc/) - [RC 2](/docs/tde/upstream/release-notes/rc2/) - [1.0.0](/docs/tde/upstream/release-notes/release-notes-v1.0/) - [2.0.0](/docs/tde/upstream/release-notes/release-notes-v2.0/) - [2.1.0](/docs/tde/upstream/release-notes/release-notes-v2.1/) - [2.1.1](/docs/tde/upstream/release-notes/release-notes-v2.1.1/) - [2.1.2](/docs/tde/upstream/release-notes/release-notes-v2.1.2/) - [2.2.0](/docs/tde/upstream/release-notes/release-notes-v2.2.0/) - [2.2.1](/docs/tde/upstream/release-notes/release-notes-v2.2.1/) - [2.2.2](/docs/tde/upstream/release-notes/release-notes-v2.2.2/) - [pg_tde 2.3.0 (2026-11-17)](/docs/tde/upstream/release-notes/release-notes-v2.3.0/) ================ Source: https://mimus.pgsty.com/docs/tde/upstream/apt/index.md ================ # Install pg_tde on Debian or Ubuntu > Install the separate pg_tde package from Percona’s Debian and Ubuntu repositories. --- LLMS index: [llms.txt](/llms.txt) --- > The packages and support matrix below belong to Percona PostgreSQL. Build pg_tde against the matching Mimus installation before enabling it. [Mimus procedure](/docs/reference/patches/base/#components) This page explains how to install `pg_tde` for [Percona Distribution for PostgreSQL ](https://docs.percona.com/postgresql/latest/index.html). > [!TIP] > Check the [list of supported platforms ](https://www.percona.com/services/policies/percona-software-support-lifecycle) before continuing. ## Preconditions {#preconditions} 1. Remove any upstream PostgreSQL packages (postgresql-*) that may already be installed on Debian or other apt-based systems. These packages conflict with Percona Server for PostgreSQL and with the standalone `pg_tde` package. 2. Ensure you enable the Percona APT repository using the repository management tool `percona-release`. This ensures the correct Percona Server for PostgreSQL and pg_tde packages are available for installation. ## Install percona-release {#install-percona-release} 1. You need the following dependencies to install `percona-release`: - `wget` - `gnupg2` - `curl` - `lsb-release` Install the dependencies: ```bash sudo apt-get install -y wget gnupg2 curl lsb-release ``` 2. Fetch the `percona-release` package ```bash sudo wget https://repo.percona.com/apt/percona-release_latest.generic_all.deb ``` 3. Install `percona-release` ```bash sudo dpkg -i percona-release_latest.generic_all.deb ``` 4. Enable the Percona Distribution for PostgreSQL repository ```bash sudo percona-release enable-only ppg-18 ``` 5. Update the local cache ```bash sudo apt-get update ``` ## Install pg_tde {#install-pgtde} After all [preconditions](#preconditions) are met, install the `pg_tde` package: ```bash sudo apt-get install -y percona-pg-tde(pg-version) ``` ### Example for PostgreSQL 18 {#example-for-postgresql-18} ```bash sudo apt-get install -y percona-pg-tde18 ``` ## Next steps {#next-steps} [Configure pg_tde ](/docs/tde/upstream/setup/) [PG.CENTER edition](https://github.com/pgsty/doc.pg.center/blob/4410c32dc9186a22859008303f474b72a779f583/content/percona/apt.md) · [Upstream source](https://github.com/percona/pg_tde/blob/5dd7a9e4e3599d88546f5de67ff0f4ef3fe51a9a/documentation/docs/apt.md) --- Backlinks: - [Get started](/docs/tde/upstream/install/) ================ Source: https://mimus.pgsty.com/docs/tde/upstream/yum/index.md ================ # Install pg_tde on Red Hat Enterprise Linux and Derivatives > Install the pg_tde RPM package on Red Hat Enterprise Linux and compatible distributions. --- LLMS index: [llms.txt](/llms.txt) --- > The packages and support matrix below belong to Percona PostgreSQL. Build pg_tde against the matching Mimus installation before enabling it. [Mimus procedure](/docs/reference/patches/base/#components) This tutorial shows how to install `pg_tde` with [Percona Distribution for PostgreSQL](https://docs.percona.com/postgresql/latest/index.html). > [!TIP] > Check the [list of supported platforms ](https://www.percona.com/services/policies/percona-software-support-lifecycle) before continuing. ## Install percona-release {#install-percona-release} You need the `percona-release` repository management tool that enables the desired Percona repository for you. 1. Install `percona-release`: ```bash sudo yum -y install https://repo.percona.com/yum/percona-release-latest.noarch.rpm ``` 2. Enable the repository: ```bash sudo percona-release enable-only ppg-18 ``` ## Install pg_tde {#install-pgtde} Install `pg_tde`: ```bash sudo yum install -y percona-pg_tde(pg-version) ``` ### Example for PostgreSQL 18 {#example-for-postgresql-18} ```bash sudo yum install -y percona-pg_tde18 ``` ## Next steps {#next-steps} [Configure pg_tde ](/docs/tde/upstream/setup/) [PG.CENTER edition](https://github.com/pgsty/doc.pg.center/blob/4410c32dc9186a22859008303f474b72a779f583/content/percona/yum.md) · [Upstream source](https://github.com/percona/pg_tde/blob/5dd7a9e4e3599d88546f5de67ff0f4ef3fe51a9a/documentation/docs/yum.md) --- Backlinks: - [Get started](/docs/tde/upstream/install/) ================ Source: https://mimus.pgsty.com/docs/tde/upstream/setup/index.md ================ # Configure pg_tde > Preload the library, restart PostgreSQL, and enable the extension in a database. --- LLMS index: [llms.txt](/llms.txt) --- > The packages and support matrix below belong to Percona PostgreSQL. Build pg_tde against the matching Mimus installation before enabling it. [Mimus procedure](/docs/reference/patches/base/#components) Before you can use `pg_tde` for data encryption, you must enable the extension and configure PostgreSQL to load it at startup. This setup ensures that the necessary hooks and shared memory are available for encryption operations. > [!NOTE] > To learn how to configure multi-tenancy, refer to the [Configure multi-tenancy](/docs/tde/upstream/how-to/multi-tenant-setup/) guidelines. The `pg_tde` extension requires additional shared memory. You need to configure PostgreSQL to preload it at startup. ## 1. Configure shared_preload_libraries {#1-configure-sharedpreloadlibraries} You can configure the `shared_preload_libraries` parameter in two ways: * Add the following line to the `postgresql.conf` file: ```bash shared_preload_libraries = 'pg_tde' ``` * Use the [ALTER SYSTEM ](https://www.postgresql.org/docs/current/sql-altersystem.html) command. Run the following command in `psql` as a **superuser**: ```sql ALTER SYSTEM SET shared_preload_libraries = 'pg_tde'; ``` ## 2. Restart the PostgreSQL cluster {#2-restart-the-postgresql-cluster} Restart the `postgresql` cluster to apply the configuration. * On Debian and Ubuntu: ```sh sudo systemctl restart postgresql.service ``` * On RHEL and derivatives: ```sh sudo systemctl restart postgresql-17 ``` ## 3. Create the extension {#3-create-the-extension} After restarting PostgreSQL, connect to `psql` as a **superuser** or **database owner** and run: ```sql CREATE EXTENSION pg_tde; ``` See [CREATE EXTENSION ](https://www.postgresql.org/docs/current/sql-createextension.html) for more details. > [!NOTE] > The `pg_tde` extension is created only for the current database. To enable it for other databases, you must run the command in each individual database. ## 4. (Optional) Enable pg_tde by default {#4-optional-enable-pgtde-by-default} To automatically have `pg_tde` enabled for all new databases, modify the `template1` database: ```sql psql -d template1 -c 'CREATE EXTENSION pg_tde;' ``` > [!NOTE] > It’s recommended to use an external key provider (KMS) to manage encryption keys. For configuration instructions, see [Next steps](#next-steps). ## Next steps {#next-steps} [Configure Key Management (KMS) ](/docs/tde/upstream/global-key-provider-configuration/overview/) [PG.CENTER edition](https://github.com/pgsty/doc.pg.center/blob/4410c32dc9186a22859008303f474b72a779f583/content/percona/setup.md) · [Upstream source](https://github.com/percona/pg_tde/blob/5dd7a9e4e3599d88546f5de67ff0f4ef3fe51a9a/documentation/docs/setup.md) --- Backlinks: - [Debian / Ubuntu](/docs/tde/upstream/apt/) - [Configure multi-tenancy](/docs/tde/upstream/how-to/multi-tenant-setup/) - [Table access methods](/docs/tde/upstream/index/table-access-method/) - [Get started](/docs/tde/upstream/install/) - [Streaming replication](/docs/tde/upstream/replication/) - [Verify encryption](/docs/tde/upstream/test/) - [RHEL / Rocky / Alma](/docs/tde/upstream/yum/) ================ Source: https://mimus.pgsty.com/docs/tde/upstream/test/index.md ================ # Validate Encryption with pg_tde > Create or convert a table with tde_heap and verify its encryption status. --- LLMS index: [llms.txt](/llms.txt) --- > This is the Percona pg_tde 2.3.0 manual. For the paired build, backup tools and major upgrades, see [PG TDE on Mimus](/docs/tde/). After enabling the `pg_tde` extension for a database, you can begin encrypting data using the `tde_heap` table access method. ## Encrypt data in a new table {#encrypt-data-in-a-new-table} 1. Create a table in the database for which you have [enabled `pg_tde`](/docs/tde/upstream/setup/) using the `tde_heap` access method as follows: ```sql CREATE TABLE ( ) USING tde_heap; ``` **Warning:** Example for testing purposes only: ```sql CREATE TABLE albums ( album_id INTEGER GENERATED ALWAYS AS IDENTITY PRIMARY KEY, artist_id INTEGER, title TEXT NOT NULL, released DATE NOT NULL ) USING tde_heap; ``` Learn more about table access methods and how you can enable data encryption by default in the [Table Access Methods and TDE](/docs/tde/upstream/index/table-access-method/) section. 2. To check if the data is encrypted, run the following function: ```sql SELECT pg_tde_is_encrypted('table_name'); ``` The function returns `true` or `false`. 3. (Optional) Rotate the principal key. To re-encrypt the data using a new key, see [Principal key management](/docs/tde/upstream/functions/#principal-key-management). ## Encrypt existing table {#encrypt-existing-table} You can encrypt an existing table. It requires rewriting the table, so for large tables, it might take a considerable amount of time. Run the following command: ```sql ALTER TABLE table_name SET ACCESS METHOD tde_heap; ``` > [!IMPORTANT] > Using `SET ACCESS METHOD` drops hint bits which can impact query performance. To restore performance, run: > > ```sql > SELECT count(*) FROM table_name; > ``` > > This forces PostgreSQL to check every tuple for visibility and reset the hint bits. > [!TIP] > Want to remove encryption later? See how to [decrypt your data](/docs/tde/upstream/how-to/decrypt/). ## Next steps {#next-steps} [Configure WAL encryption ](/docs/tde/upstream/wal-encryption/) [PG.CENTER edition](https://github.com/pgsty/doc.pg.center/blob/4410c32dc9186a22859008303f474b72a779f583/content/percona/test.md) · [Upstream source](https://github.com/percona/pg_tde/blob/5dd7a9e4e3599d88546f5de67ff0f4ef3fe51a9a/documentation/docs/test.md) --- Backlinks: - [A production checklist for pg_tde](/docs/tde/upstream/blog/guide/production-checklist/) - [An early look at pg_tde](/docs/tde/upstream/blog/percona/early-project-update/) - [FAQ](/docs/tde/upstream/faq/) - [Features](/docs/tde/upstream/features/) - [Local keyring](/docs/tde/upstream/global-key-provider-configuration/keyring/) - [Default principal key](/docs/tde/upstream/global-key-provider-configuration/set-principal-key/) - [Get started](/docs/tde/upstream/install/) - [Beta](/docs/tde/upstream/release-notes/beta/) ================ Source: https://mimus.pgsty.com/docs/tde/upstream/global-key-provider-configuration/index.md ================ # Key management > Configure keyring files and external key management systems. --- LLMS index: [llms.txt](/llms.txt) --- > This is the Percona pg_tde 2.3.0 manual. For the paired build, backup tools and major upgrades, see [PG TDE on Mimus](/docs/tde/). [PG.CENTER edition](https://github.com/pgsty/doc.pg.center/blob/4410c32dc9186a22859008303f474b72a779f583/content/percona/global-key-provider-configuration/_index.md) · [Upstream source](https://github.com/percona/pg_tde/tree/5dd7a9e4e3599d88546f5de67ff0f4ef3fe51a9a) --- Section pages: - [Key management overview](/docs/tde/upstream/global-key-provider-configuration/overview/): Choose a supported KMS and understand principal keys, provider scope, and deployment requirements. - [Keyring file configuration](/docs/tde/upstream/global-key-provider-configuration/keyring/): Configure a plaintext file keyring for local development and testing. - [Vault configuration](/docs/tde/upstream/global-key-provider-configuration/vault/): Connect pg_tde to a HashiCorp Vault KV v2 secrets engine. - [Using OpenBao as a key provider](/docs/tde/upstream/global-key-provider-configuration/openbao/): Configure an OpenBao secrets engine, token, and pg_tde key provider. - [KMIP configuration](/docs/tde/upstream/global-key-provider-configuration/kmip-server/): Configure a KMIP endpoint, client credentials, and key provider. - [Thales KMIP server configuration](/docs/tde/upstream/global-key-provider-configuration/kmip-thales/): Connect pg_tde to Thales CipherTrust Manager through KMIP. - [Fortanix KMIP server configuration](/docs/tde/upstream/global-key-provider-configuration/kmip-fortanix/): Prepare a Fortanix DSM security object, certificate, and KMIP endpoint. - [Akeyless KMIP server configuration](/docs/tde/upstream/global-key-provider-configuration/kmip-akeyless/): Create Akeyless KMIP credentials and connect a pg_tde key provider. - [Default principal key configuration](/docs/tde/upstream/global-key-provider-configuration/set-principal-key/): Assign a default principal key to databases without their own configured key. --- Backlinks: - [PG TDE](/docs/tde/) - [Keys and WAL encryption](/docs/tde/keys/) - [Percona pg_tde 2.3.0](/docs/tde/upstream/) ================ Source: https://mimus.pgsty.com/docs/tde/upstream/global-key-provider-configuration/overview/index.md ================ # Key management overview > Choose a supported KMS and understand principal keys, provider scope, and deployment requirements. --- LLMS index: [llms.txt](/llms.txt) --- > This is the Percona pg_tde 2.3.0 manual. For the paired build, backup tools and major upgrades, see [PG TDE on Mimus](/docs/tde/). > [!NOTE] Editorial correction > This overview retains an older qualification of Vault KMIP. The 2.2.2 release notes explicitly announce Vault Enterprise KMIP support; consult those notes for the version-specific status. See [site errata](/docs/tde/upstream/site/errata/). In production environments, storing encryption keys locally on the PostgreSQL server can introduce security risks. To enhance security, `pg_tde` supports integration with external Key Management Systems (KMS) through a Global Key Provider interface. This section describes how you can configure `pg_tde` to use the local and external key providers. To use an external KMS with `pg_tde`: 1. Configure a Key Provider 2. Set the [Global Principal Key](/docs/tde/upstream/global-key-provider-configuration/set-principal-key/) > [!NOTE] > While key files may be acceptable for **local** or **testing environments**, KMS integration is the recommended approach for production deployments. > [!IMPORTANT] > When using HashiCorp Vault, **KV v2 is the recommended and supported integration method**. > > The KMIP engine in Vault is not a validated configuration for `pg_tde` and is not recommended for production deployments. > [!WARNING] > Do not rotate encryption keys while a backup is running. This may result in an inconsistent backup and restore failure. This applies to all backup tools. > > Schedule key rotations outside backup windows. After rotating keys, take a new full backup. > > For more details, see [Limitations of pg_tde](/docs/tde/upstream/index/tde-limitations/#limitations-when-using-pgtde). `pg_tde` has been tested with the following key providers: | KMS Provider | Description | Documentation | |--------------------|-------------------------------------------------------|---------------| | **KMIP** | Standard Key Management Interoperability Protocol. | [Configure KMIP →](/docs/tde/upstream/global-key-provider-configuration/kmip-server/) | | **Vault** | HashiCorp Vault integration (KV v2 API). | [Configure Vault →](/docs/tde/upstream/global-key-provider-configuration/vault/) | | **Fortanix** | Fortanix DSM key management. | [Configure Fortanix →](/docs/tde/upstream/global-key-provider-configuration/kmip-fortanix/) | | **Thales** | Thales CipherTrust Manager and DSM. | [Configure Thales →](/docs/tde/upstream/global-key-provider-configuration/kmip-thales/) | | **OpenBao** | Community fork of Vault, supporting KV v2. | [Configure OpenBao →](/docs/tde/upstream/global-key-provider-configuration/openbao/) | | **Akeyless** | A cloud-based secrets management platform for securely storing and accessing credentials and encryption keys. | [Configure Akeyless →](/docs/tde/upstream/global-key-provider-configuration/kmip-akeyless/) | | **Keyring file** *(not recommended)* | Local key file for dev/test only. | [Configure keyring file →](/docs/tde/upstream/global-key-provider-configuration/keyring/) | [PG.CENTER edition](https://github.com/pgsty/doc.pg.center/blob/4410c32dc9186a22859008303f474b72a779f583/content/percona/global-key-provider-configuration/overview.md) · [Upstream source](https://github.com/percona/pg_tde/blob/5dd7a9e4e3599d88546f5de67ff0f4ef3fe51a9a/documentation/docs/global-key-provider-configuration/overview.md) --- Backlinks: - [Keys and providers](/docs/tde/upstream/architecture/key-provider-management/) - [Architecture overview](/docs/tde/upstream/architecture/overview/) - [How pg_tde keeps data encrypted through PostgreSQL storage](/docs/tde/upstream/blog/guide/encryption-architecture/) - [A production checklist for pg_tde](/docs/tde/upstream/blog/guide/production-checklist/) - [Questions from the PostgreSQL TDE webinar](/docs/tde/upstream/blog/percona/webinar-qa/) - [Features](/docs/tde/upstream/features/) - [SQL functions](/docs/tde/upstream/functions/) - [Local keyring](/docs/tde/upstream/global-key-provider-configuration/keyring/) - [Configure multi-tenancy](/docs/tde/upstream/how-to/multi-tenant-setup/) - [How it works](/docs/tde/upstream/index/how-does-tde-work/) - [Get started](/docs/tde/upstream/install/) - [2.1.0](/docs/tde/upstream/release-notes/release-notes-v2.1/) - [Load the extension](/docs/tde/upstream/setup/) - [Documentation errata](/docs/tde/upstream/site/errata/) - [WAL encryption](/docs/tde/upstream/wal-encryption/) ================ Source: https://mimus.pgsty.com/docs/tde/upstream/global-key-provider-configuration/keyring/index.md ================ # Keyring file configuration > Configure a plaintext file keyring for local development and testing. --- LLMS index: [llms.txt](/llms.txt) --- > This is the Percona pg_tde 2.3.0 manual. For the paired build, backup tools and major upgrades, see [PG TDE on Mimus](/docs/tde/). > [!NOTE] Editorial correction > The inspection example now uses the table it creates and the current database key-info function. See [site errata](/docs/tde/upstream/site/errata/). This setup is intended for development and stores the keys, unencrypted, in a data file you specify. > [!NOTE] > While keyring files may be acceptable for **local** or **testing environments**, proper [KMS providers](/docs/tde/upstream/global-key-provider-configuration/overview/) are the recommended approach for production deployments. You can configure key providers either at the database level (for development and testing) or at the global level (for production). The steps below provide an example on how to add a [database-scoped key provider](/docs/tde/upstream/functions/#add-or-modify-local-key-file-providers): 1. Create a database-scoped file key provider (`file-keyring` in this example) in the `/tmp/pg_tde_test_local_keyring.per` file: ```sql SELECT pg_tde_add_database_key_provider_file( 'file-keyring', '/tmp/pg_tde_test_local_keyring.per' ); ``` 2. Create a key (`my_default_key` in this example) inside the newly created `file-keyring` provider: ```sql SELECT pg_tde_create_key_using_database_key_provider( 'my_default_key', 'file-keyring' ); ``` 3. Set the key (`my_default_key`) from the key provider (`file-keyring`): ```sql SELECT pg_tde_set_key_using_database_key_provider( 'my_default_key', 'file-keyring' ); ``` > [!TIP] > You can check the current database key information (such as the date and time of creation). Run: > > ```sql > SELECT pg_tde_key_info(); > ``` 4. Now, create a table using [tde_heap](/docs/tde/upstream/index/table-access-method/#how-tdeheap-works-with-pgtde): ```sql CREATE TABLE customer_table (a INT) USING tde_heap; ``` The newly created table is encrypted with the database key you have set (`my_default_key`). > [!TIP] > To check if your created table is encrypted with tde_heap, run: > > ```sql > \d+ customer_table > ``` > > If `Access method: tde_heap`, then your table is encrypted. > > > [!DETAILS] Example output > > postgres=# \d+ customer_table > > Table "public.customer_table" > > Column | Type | Collation | Nullable | Default | Storage | Compression | Stats target | Description > > --------+---------+-----------+----------+---------+---------+-------------+--------------+------------- > > a | integer | | | | plain | | | > > Access method: tde_heap ## Further reading {#further-reading} Next, for production deployments, [configure a global principal key](/docs/tde/upstream/global-key-provider-configuration/set-principal-key/) using a proper [KMS provider](/docs/tde/upstream/global-key-provider-configuration/overview/). Alternatively, you can skip directly to [validating encryption with pg_tde](/docs/tde/upstream/test/) or [configuring WAL encryption](/docs/tde/upstream/wal-encryption/). You can also review the available `pg_tde` functions in [Functions](/docs/tde/upstream/functions/). [PG.CENTER edition](https://github.com/pgsty/doc.pg.center/blob/4410c32dc9186a22859008303f474b72a779f583/content/percona/global-key-provider-configuration/keyring.md) · [Upstream source](https://github.com/percona/pg_tde/blob/5dd7a9e4e3599d88546f5de67ff0f4ef3fe51a9a/documentation/docs/global-key-provider-configuration/keyring.md) --- Backlinks: - [Choose a provider](/docs/tde/upstream/global-key-provider-configuration/overview/) - [Documentation errata](/docs/tde/upstream/site/errata/) ================ Source: https://mimus.pgsty.com/docs/tde/upstream/global-key-provider-configuration/vault/index.md ================ # Vault configuration > Connect pg_tde to a HashiCorp Vault KV v2 secrets engine. --- LLMS index: [llms.txt](/llms.txt) --- > This is the Percona pg_tde 2.3.0 manual. For the paired build, backup tools and major upgrades, see [PG TDE on Mimus](/docs/tde/). You can configure `pg_tde` to use HashiCorp Vault as a global key provider for managing encryption keys securely. Both the open source and enterprise editions are supported. ## Configure Vault with pg_tde in Docker {#configure-vault-with-pgtde-in-docker} This example setup describes how to run HashiCorp Vault and Percona PostgreSQL with `pg_tde` side by side using Docker, configure Vault policies, and connect it as a global key provider for TDE encryption. > [!NOTE] > For production deployments, follow your organization’s security standards. ### 1. Create the docker-compose.yaml file {#1-create-the-docker-compose-yaml-file} The following `docker-compose.yaml` file is an example on how to run both Vault and PostgreSQL with a shared secrets volume: > [!DETAILS] docker-compose.yaml (example file) > > ```bash > version: '3.8' > > services: > vault: > image: hashicorp/vault:latest > container_name: vault > ports: > - "8200:8200" > volumes: > - ./vault-config.hcl:/vault/config/vault-config.hcl > - ./vault-data:/vault/data > - shared-secrets:/vault/secrets > environment: > VAULT_ADDR: http://127.0.0.1:8200 > command: vault server -config=/vault/config/vault-config.hcl > > pg: > image: percona/percona-distribution-postgresql:17.5-2 > container_name: pg > ports: > - "5432:5432" > environment: > POSTGRES_PASSWORD: secret > ENABLE_PG_TDE: "1" > volumes: > - ./pgdata:/var/lib/postgresql/data > - shared-secrets:/etc/postgresql/secrets:ro > depends_on: > - vault > > volumes: > shared-secrets: > ``` ### 2. Enable the KV v2 secrets engine {#2-enable-the-kv-v2-secrets-engine} In the Vault container, enable a KV v2 storage engine for `pg_tde`: ```bash vault secrets enable -path=tde -version=2 kv ``` This creates a `tde/` mount for storing encrypted keys. > [!NOTE] Vault namespaces (Enterprise) and mounts > If you are using **Vault Enterprise namespaces**, you don’t need a separate > namespace parameter when configuring `pg_tde`. > > You can include the namespace directly in the mount path. For example: > > ```sql > SELECT pg_tde_add_global_key_provider_vault_v2( > 'vault-ns', > 'https://127.0.0.1:8200', > 'pgns/tde/data/global-key', > '/etc/postgresql/secrets/vault_token.txt', > NULL > ); > ``` > > This is equivalent to configuring a namespace separately and works with both: > > * Vault OSS > * Vault Enterprise (with namespaces) ### 3. Create a Vault policy for pg_tde {#3-create-a-vault-policy-for-pgtde} Define a Vault policy that grants `pg_tde` access to read, write, and list keys. ```bash vault policy write tde-policy - < [!TIP] > > If you encounter the following error: > > ```sql > ERROR: failed to get mount info for "http://vault:8200" at mountpoint ... > ``` > > Ensure your Vault policy includes the following path: > > ```ini > path "sys/mounts/*" { > capabilities = ["read"] > } > ``` > > This allows `pg_tde` to read the mount metadata from Vault. ### 4. Create an Authentication Method and Token {#4-create-an-authentication-method-and-token} Enable the AppRole authentication method: ```bash vault auth enable approle vault write auth/approle/role/tde-role policies="tde-policy" ``` Generate a token associated with the tde-policy: ```bash vault token create -policy="tde-policy" ``` Example output: ```css Key Value token hvs.{secret_code} token_policies ["default" "tde-policy"] ``` ### 5. Share the token with PostgreSQL {#5-share-the-token-with-postgresql} Copy the generated token into the shared secrets directory (shared secrets volume) so PostgreSQL can use it: ```bash echo "hvs.secret_code" > /vault/secrets/vault_token.txt ``` > [!TIP] > You can access this file in PostgreSQL at `/etc/postgresql/secrets/vault_token.txt`. ### 6. Register Vault as a global key provider in PostgreSQL {#6-register-vault-as-a-global-key-provider-in-postgresql} In the PostgreSQL container, connect `pg_tde` to Vault using: ```sql SELECT pg_tde_add_global_key_provider_vault_v2( 'vault-provider', 'http://vault:8200', 'tde/data/global-key', '/etc/postgresql/secrets/vault_token.txt', NULL ); ``` ### 7. Create and set the global master key {#7-create-and-set-the-global-master-key} Create the global master key: ```sql SELECT pg_tde_create_key_using_global_key_provider( 'global-master-key', 'vault-provider' ); ``` Then set it: ```sql SELECT pg_tde_set_default_key_using_global_key_provider( 'global-master-key', 'vault-provider' ); ``` ### 8. Test encryption with a sample table {#8-test-encryption-with-a-sample-table} Create a sample table: ```sql CREATE TABLE secure_data ( id INTEGER GENERATED ALWAYS AS IDENTITY PRIMARY KEY, name TEXT, amount NUMERIC(10,2), created_at DATE ) USING tde_heap; ``` Then insert data into the table: ```sql INSERT INTO secure_data (name, amount, created_at) VALUES ('Alice', 1234.56, '2025-08-01'), ('Bob', 7890.12, '2025-08-10'), ('Charlie', 345.67, '2025-08-19'); ``` Query the table and confirm that the encryption is functioning: ```sql select * from secure_data; id | name | amount | created_at ----+---------+---------+------------ 1 | Alice | 1234.56 | 2025-08-01 2 | Bob | 7890.12 | 2025-08-10 3 | Charlie | 345.67 | 2025-08-19 (3 rows) ``` ## Example global key provider usage {#example-global-key-provider-usage} ```sql SELECT pg_tde_add_global_key_provider_vault_v2( 'provider-name', 'url', 'mount', 'secret_token_path', 'ca_path' ); ``` ## Parameter descriptions {#parameter-descriptions} * `provider-name` is the name to identify this key provider * `secret_token_path` is a path to the file that contains an access token with read and write access to the above mount point * `url` is the URL of the Vault server * `mount` is the mount point where the keyring should store the keys * [optional] `ca_path` is the path of the CA file used for SSL verification The following example is for testing purposes only. Use secure tokens and proper SSL validation in production environments: ```sql SELECT pg_tde_add_global_key_provider_vault_v2( 'my-vault', 'https://vault.vault.svc.cluster.local:8200', 'secret/data', '/path/to/token_file', '/path/to/ca_cert.pem' ); ``` For more information on related functions, see [Function Reference](/docs/tde/upstream/functions/). ## Required permissions {#required-permissions} The PostgreSQL instance requires the following Vault API capabilities to manage and read encryption keys: * `sys/mounts//*` - **read** permissions * `/data/*` - **create**, **read** permissions * `/metadata/*` - **list** permissions > [!NOTE] > For more information on Vault permissions, see the [following documentation](https://developer.hashicorp.com/vault/docs/concepts/policies). ## Next steps {#next-steps} [Global Principal Key Configuration ](/docs/tde/upstream/global-key-provider-configuration/set-principal-key/) [PG.CENTER edition](https://github.com/pgsty/doc.pg.center/blob/4410c32dc9186a22859008303f474b72a779f583/content/percona/global-key-provider-configuration/vault.md) · [Upstream source](https://github.com/percona/pg_tde/blob/5dd7a9e4e3599d88546f5de67ff0f4ef3fe51a9a/documentation/docs/global-key-provider-configuration/vault.md) --- Backlinks: - [FAQ](/docs/tde/upstream/faq/) - [KMIP setup](/docs/tde/upstream/global-key-provider-configuration/kmip-server/) - [Choose a provider](/docs/tde/upstream/global-key-provider-configuration/overview/) ================ Source: https://mimus.pgsty.com/docs/tde/upstream/global-key-provider-configuration/openbao/index.md ================ # Using OpenBao as a key provider > Configure an OpenBao secrets engine, token, and pg_tde key provider. --- LLMS index: [llms.txt](/llms.txt) --- > This is the Percona pg_tde 2.3.0 manual. For the paired build, backup tools and major upgrades, see [PG TDE on Mimus](/docs/tde/). You can configure `pg_tde` to use OpenBao as a global key provider for managing encryption keys securely. > [!NOTE] > This guide assumes that your OpenBao server is already set up and accessible. OpenBao configuration is outside the scope of this document, see [OpenBao's official documentation](https://openbao.org/docs/) for more information. ## Example usage {#example-usage} To register an OpenBao server as a global key provider: ```sql SELECT pg_tde_add_global_key_provider_vault_v2( 'provider-name', 'url', 'mount', 'secret_token_path', 'ca_path', 'namespace' ); ``` ## Parameter descriptions {#parameter-descriptions} * `provider-name` is the name to identify this key provider * `secret_token_path` is a path to the file that contains an access token with read and write access to the above mount point * `url` is the URL of the OpenBao server * `mount` is the mount point where the keyring should store the keys * [optional] `ca_path` is the path of the CA file used for SSL verification * [optional] `namespace` is the namespace within the OpenBao server. Read more about the [namespace support in OpenBao](https://openbao.org/blog/namespaces-announcement/)` (NOTE: You can use a namespace without ca_path. In this case, specify NULL as the ca_path value) The following example is for testing purposes only. Use secure tokens and proper SSL validation in production environments: ```sql SELECT pg_tde_add_global_key_provider_vault_v2( 'my-openbao-provider', 'https://openbao.example.com:8200', 'secret/data', '/path/to/token_file', '/path/to/ca_cert.pem' ); ``` For more information on related functions, see the link below: [Percona pg_tde Function Reference](/docs/tde/upstream/functions/) ## Next steps {#next-steps} [Global Principal Key Configuration ](/docs/tde/upstream/global-key-provider-configuration/set-principal-key/) [PG.CENTER edition](https://github.com/pgsty/doc.pg.center/blob/4410c32dc9186a22859008303f474b72a779f583/content/percona/global-key-provider-configuration/openbao.md) · [Upstream source](https://github.com/percona/pg_tde/blob/5dd7a9e4e3599d88546f5de67ff0f4ef3fe51a9a/documentation/docs/global-key-provider-configuration/openbao.md) --- Backlinks: - [Choose a provider](/docs/tde/upstream/global-key-provider-configuration/overview/) ================ Source: https://mimus.pgsty.com/docs/tde/upstream/global-key-provider-configuration/kmip-server/index.md ================ # KMIP configuration > Configure a KMIP endpoint, client credentials, and key provider. --- LLMS index: [llms.txt](/llms.txt) --- > This is the Percona pg_tde 2.3.0 manual. For the paired build, backup tools and major upgrades, see [PG TDE on Mimus](/docs/tde/). > [!NOTE] Editorial correction > This overview retains an older qualification of Vault KMIP. The 2.2.2 release notes explicitly announce Vault Enterprise KMIP support; consult those notes for the version-specific status. See [site errata](/docs/tde/upstream/site/errata/). To use a Key Management Interoperability Protocol (KMIP) server with `pg_tde`, you must configure it as a global key provider. This setup enables `pg_tde` to securely fetch and manage encryption keys from a centralized key management appliance. > [!IMPORTANT] > When using HashiCorp Vault as a KMIP server, this configuration is not a validated deployment model for `pg_tde` and is not recommended for production use. > > For Vault-based key management, use the [KV v2 integration](/docs/tde/upstream/global-key-provider-configuration/vault/) instead. > [!NOTE] > You need the root certificate of the KMIP server and a client key/certificate pair with permissions to create and read keys on the server. For testing purposes, you can use a Eviden KMS server, which enables easy certificate generation and basic KMIP behavior. If you're using a production-grade KMIP server, ensure you obtain valid, trusted certificates from the key management appliance. ## Example usage {#example-usage} ```sql SELECT pg_tde_add_global_key_provider_kmip( 'provider-name', 'kmip-IP', `port`, '/path_to/server_certificate.pem', '/path_to/client_cert.pem', '/path_to/client_key.pem' ); ``` ## Parameter descriptions {#parameter-descriptions} * `provider-name` is the name of the provider. You can specify any name, it's for you to identify the provider * `kmip-IP` is the IP address of a domain name of the KMIP server * `port` is the port to communicate with the KMIP server. Typically used port is 5696 * `server-certificate` is the path to the certificate file for the KMIP server * `client_cert` is the path to the client certificate. * `client_key` is the path to the client key. The following example is for testing purposes only. ```sql SELECT pg_tde_add_global_key_provider_kmip( 'kmip','127.0.0.1', 5696, '/tmp/server_certificate.pem', '/tmp/client_cert_jane_doe.pem', '/tmp/client_key_jane_doe.pem' ); ``` For more information on related functions, see the link below: [Percona pg_tde Function Reference](/docs/tde/upstream/functions/) ## Next steps {#next-steps} [Global Principal Key Configuration ](/docs/tde/upstream/global-key-provider-configuration/set-principal-key/) [PG.CENTER edition](https://github.com/pgsty/doc.pg.center/blob/4410c32dc9186a22859008303f474b72a779f583/content/percona/global-key-provider-configuration/kmip-server.md) · [Upstream source](https://github.com/percona/pg_tde/blob/5dd7a9e4e3599d88546f5de67ff0f4ef3fe51a9a/documentation/docs/global-key-provider-configuration/kmip-server.md) --- Backlinks: - [FAQ](/docs/tde/upstream/faq/) - [Choose a provider](/docs/tde/upstream/global-key-provider-configuration/overview/) ================ Source: https://mimus.pgsty.com/docs/tde/upstream/global-key-provider-configuration/kmip-thales/index.md ================ # Thales KMIP server configuration > Connect pg_tde to Thales CipherTrust Manager through KMIP. --- LLMS index: [llms.txt](/llms.txt) --- > This is the Percona pg_tde 2.3.0 manual. For the paired build, backup tools and major upgrades, see [PG TDE on Mimus](/docs/tde/). `pg_tde` is compatible with the Thales CipherTrust Manager via the KMIP protocol. For a full setup guide, see [the Thales documentation](https://thalesdocs.com/ctp/cm/2.19/reference/kmip-ref/index.html?). For more information on adding or modifying the provider, see the [Adding or modifying KMIP providers](/docs/tde/upstream/functions/#add-or-modify-kmip-providers) topic. [PG.CENTER edition](https://github.com/pgsty/doc.pg.center/blob/4410c32dc9186a22859008303f474b72a779f583/content/percona/global-key-provider-configuration/kmip-thales.md) · [Upstream source](https://github.com/percona/pg_tde/blob/5dd7a9e4e3599d88546f5de67ff0f4ef3fe51a9a/documentation/docs/global-key-provider-configuration/kmip-thales.md) --- Backlinks: - [Choose a provider](/docs/tde/upstream/global-key-provider-configuration/overview/) ================ Source: https://mimus.pgsty.com/docs/tde/upstream/global-key-provider-configuration/kmip-fortanix/index.md ================ # Fortanix KMIP server configuration > Prepare a Fortanix DSM security object, certificate, and KMIP endpoint. --- LLMS index: [llms.txt](/llms.txt) --- > This is the Percona pg_tde 2.3.0 manual. For the paired build, backup tools and major upgrades, see [PG TDE on Mimus](/docs/tde/). `pg_tde` is compatible with Fortanix Data Security Manager (DSM) via the KMIP protocol. For a full setup guide, see [the Fortanix KMIP documentation here](https://support.fortanix.com/docs). For more information on adding or modifying the provider, see the [Adding or modifying KMIP providers](/docs/tde/upstream/functions/#add-or-modify-kmip-providers) topic. [PG.CENTER edition](https://github.com/pgsty/doc.pg.center/blob/4410c32dc9186a22859008303f474b72a779f583/content/percona/global-key-provider-configuration/kmip-fortanix.md) · [Upstream source](https://github.com/percona/pg_tde/blob/5dd7a9e4e3599d88546f5de67ff0f4ef3fe51a9a/documentation/docs/global-key-provider-configuration/kmip-fortanix.md) --- Backlinks: - [Choose a provider](/docs/tde/upstream/global-key-provider-configuration/overview/) ================ Source: https://mimus.pgsty.com/docs/tde/upstream/global-key-provider-configuration/kmip-akeyless/index.md ================ # Akeyless KMIP server configuration > Create Akeyless KMIP credentials and connect a pg_tde key provider. --- LLMS index: [llms.txt](/llms.txt) --- > This is the Percona pg_tde 2.3.0 manual. For the paired build, backup tools and major upgrades, see [PG TDE on Mimus](/docs/tde/). `pg_tde` is compatible with the Akeyless CipherTrust Manager via the KMIP protocol. For a full setup guide, see [the Akeyless documentation ](https://docs.akeyless.io/docs/akeyless-overview). For more information on adding or modifying the provider, see the [Add or modify KMIP providers](/docs/tde/upstream/functions/#add-or-modify-kmip-providers) topic. ## Next steps {#next-steps} [Global Principal Key Configuration ](/docs/tde/upstream/global-key-provider-configuration/set-principal-key/) [PG.CENTER edition](https://github.com/pgsty/doc.pg.center/blob/4410c32dc9186a22859008303f474b72a779f583/content/percona/global-key-provider-configuration/kmip-akeyless.md) · [Upstream source](https://github.com/percona/pg_tde/blob/5dd7a9e4e3599d88546f5de67ff0f4ef3fe51a9a/documentation/docs/global-key-provider-configuration/kmip-akeyless.md) --- Backlinks: - [Choose a provider](/docs/tde/upstream/global-key-provider-configuration/overview/) - [2.1.0](/docs/tde/upstream/release-notes/release-notes-v2.1/) ================ Source: https://mimus.pgsty.com/docs/tde/upstream/global-key-provider-configuration/set-principal-key/index.md ================ # Default principal key configuration > Assign a default principal key to databases without their own configured key. --- LLMS index: [llms.txt](/llms.txt) --- > This is the Percona pg_tde 2.3.0 manual. For the paired build, backup tools and major upgrades, see [PG TDE on Mimus](/docs/tde/). You can configure a default principal key for the server using a global key provider. This key is used by all databases that do not have their own encryption keys configured. Configuring the default principal key is a multi-step process that uses the following functions: - [pg_tde_add_global_key_provider_()](/docs/tde/upstream/advanced-topics/usage-guide/#add-providers) adds a global key provider - [pg_tde_create_key_using_global_key_provider()](/docs/tde/upstream/functions/#pgtdecreatekeyusingglobalkeyprovider) creates a principal key at a global key provider - [pg_tde_set_default_key_using_global_key_provider()](/docs/tde/upstream/functions/#pgtdesetdefaultkeyusingglobalkeyprovider) sets the default principal key and rotates the internal encryption key if one is already configured ## Add a global key provider {#add-a-global-key-provider} To add a global key provider, see the [Key provider management](/docs/tde/upstream/functions/#key-provider-management) topic. ## Create a default principal key {#create-a-default-principal-key} > [!NOTE] > The sample output below is for demonstration purposes only. Be sure to replace the key name and provider with your actual values. To create a global principal key, run: ```sql SELECT pg_tde_create_key_using_global_key_provider( 'key-name', 'global_vault_provider' ); ``` > [!DETAILS] Sample output > ```sql > postgres=# SELECT pg_tde_create_key_using_global_key_provider( > 'keytest1', > 'file-keyring' > ); > pg_tde_create_key_using_global_key_provider > --------------------------------------------- > > (1 row) > ``` ## Set a default principal key {#set-a-default-principal-key} To set a default principal key, run: ```sql SELECT pg_tde_set_default_key_using_global_key_provider( 'key-name', 'global_vault_provider' ); ``` > [!DETAILS] Sample output > ```sql > postgres=# SELECT pg_tde_set_default_key_using_global_key_provider( > 'keytest1', > 'file-keyring' > ); > pg_tde_set_default_key_using_global_key_provider > -------------------------------------------------- > > (1 row) > ``` ## Parameter description {#parameter-description} * `key-name` is the name under which the principal key is stored in the provider. * `global_vault_provider` is the name of the global key provider you previously configured. > [!NOTE] > > If no error is reported, the action completed successfully. ## How key generation works {#how-key-generation-works} The key material (actual cryptographic key) is auto-generated by `pg_tde` and stored securely by the configured provider. > [!NOTE] > > This process sets the **default principal key for the entire server**. Any database without a key explicitly configured will fall back to this key. ## Next steps {#next-steps} To confirm that encryption is working as expected, follow the validation steps: [Validate Encryption with pg_tde ](/docs/tde/upstream/test/) [PG.CENTER edition](https://github.com/pgsty/doc.pg.center/blob/4410c32dc9186a22859008303f474b72a779f583/content/percona/global-key-provider-configuration/set-principal-key.md) · [Upstream source](https://github.com/percona/pg_tde/blob/5dd7a9e4e3599d88546f5de67ff0f4ef3fe51a9a/documentation/docs/global-key-provider-configuration/set-principal-key.md) --- Backlinks: - [Features](/docs/tde/upstream/features/) - [Local keyring](/docs/tde/upstream/global-key-provider-configuration/keyring/) - [Akeyless](/docs/tde/upstream/global-key-provider-configuration/kmip-akeyless/) - [KMIP setup](/docs/tde/upstream/global-key-provider-configuration/kmip-server/) - [OpenBao](/docs/tde/upstream/global-key-provider-configuration/openbao/) - [Choose a provider](/docs/tde/upstream/global-key-provider-configuration/overview/) - [HashiCorp Vault](/docs/tde/upstream/global-key-provider-configuration/vault/) - [2.1.1](/docs/tde/upstream/release-notes/release-notes-v2.1.1/) - [WAL encryption](/docs/tde/upstream/wal-encryption/) ================ Source: https://mimus.pgsty.com/docs/tde/upstream/architecture/index.md ================ # Architecture > Learn how pg_tde encrypts data, manages keys, and integrates with PostgreSQL. --- LLMS index: [llms.txt](/llms.txt) --- > This is the Percona pg_tde 2.3.0 manual. For the paired build, backup tools and major upgrades, see [PG TDE on Mimus](/docs/tde/). [PG.CENTER edition](https://github.com/pgsty/doc.pg.center/blob/4410c32dc9186a22859008303f474b72a779f583/content/percona/architecture/_index.md) · [Upstream source](https://github.com/percona/pg_tde/tree/5dd7a9e4e3599d88546f5de67ff0f4ef3fe51a9a) --- Section pages: - [Architecture overview](/docs/tde/upstream/architecture/overview/): Follow encrypted tables, index files, and WAL through the pg_tde storage architecture. - [Encryption architecture](/docs/tde/upstream/architecture/encryption-architecture/): How internal keys, principal keys, AES ciphers, and WAL encryption fit together. - [Key and key provider management](/docs/tde/upstream/architecture/key-provider-management/): How key scope, provider storage, privileges, and key rotation work. ================ Source: https://mimus.pgsty.com/docs/tde/upstream/architecture/overview/index.md ================ # Architecture overview > Follow encrypted tables, index files, and WAL through the pg_tde storage architecture. --- LLMS index: [llms.txt](/llms.txt) --- > This is the Percona pg_tde 2.3.0 manual. For the paired build, backup tools and major upgrades, see [PG TDE on Mimus](/docs/tde/). `pg_tde` is a **customizable, complete, data at rest encryption extension**. Extension means that `pg_tde` is delivered as a PostgreSQL extension. > [!NOTE] > `pg_tde` relies on extensibility changes in the PostgreSQL core. It currently runs only with [Percona Server for PostgreSQL ](https://docs.percona.com/postgresql/17/index.html), which includes those changes. The following sections break down the key architectural components of this design. **a. Customizable** means that `pg_tde` supports many different use cases: * Encrypting all tables in all databases, or only selected ones * Storing encryption keys in different external key storage servers, for a list of these see [Key management overview](/docs/tde/upstream/global-key-provider-configuration/overview/) * Using a single key for a clusters, or different keys for different clusters * Centralizing all keys in one provider, or splitting them across providers * Controlling permissions: who manages keys and who can create encrypted or unencrypted tables **b. Complete** means that `pg_tde` aims to encrypt data at rest. **c. Data at rest** means everything written to the disk. This includes the following: * Table data files * Indexes * Sequences * Temporary tables * Write Ahead Log (WAL) ## Main components {#main-components} The main components of `pg_tde` are: * **Core server changes** focus on making the server more extensible, allowing the main logic of `pg_tde` to remain separate, as an extension. Core changes also add encryption-awareness to some command line tools that have to work directly with encrypted tables or encrypted WAL files. You can find the source code [here ](https://github.com/percona/postgres/tree/release-2.3). * The **`pg_tde` extension** implements the encryption code by hooking into the extension points introduced in the core changes, and the already existing extension points in the PostgreSQL server. Everything is controllable with GUC variables and SQL statements, similar to other extensions. * The **keyring API and libraries** implement the key storage logic with different key providers. The API is internal only, the keyring the libraries are currently part of the main codebase but could be separated into shared libraries in the future. [PG.CENTER edition](https://github.com/pgsty/doc.pg.center/blob/4410c32dc9186a22859008303f474b72a779f583/content/percona/architecture/overview.md) · [Upstream source](https://github.com/percona/pg_tde/blob/5dd7a9e4e3599d88546f5de67ff0f4ef3fe51a9a/documentation/docs/architecture/overview.md) --- Backlinks: - [Archive WAL](/docs/tde/upstream/command-line-tools/pg-tde-archive-decrypt/) - [Introduction](/docs/tde/upstream/overview/) - [2.1.2](/docs/tde/upstream/release-notes/release-notes-v2.1.2/) ================ Source: https://mimus.pgsty.com/docs/tde/upstream/architecture/encryption-architecture/index.md ================ # Encryption architecture > How internal keys, principal keys, AES ciphers, and WAL encryption fit together. --- LLMS index: [llms.txt](/llms.txt) --- > This is the Percona pg_tde 2.3.0 manual. For the paired build, backup tools and major upgrades, see [PG TDE on Mimus](/docs/tde/). This section explains how `pg_tde` implements encryption inside PostgreSQL. It covers the key hierarchy, supported encryption algorithms, encryption workflow, and the core changes that make it possible to encrypt tables, WAL, and other database files. Together, these components form the foundation of data-at-rest encryption in `pg_tde`. ## Two-key hierarchy {#two-key-hierarchy} ![Database principal key and internal keys](/docs/tde/upstream/assets/images/key-hierarchy-en.svg) `pg_tde` uses two kinds of keys for encryption: 1. Internal keys to encrypt the data. They are stored in PostgreSQL's data directory under `$PGDATA/pg_tde` 2. Principal keys, which encrypt internal keys, are stored externally in a Key Management System (KMS) using the key provider API `pg_tde` uses one principal key per database. Every internal key for the given database is encrypted using this principal key. Internal keys are used for specific database files: each file with a different [Object Identifier (OID) ](https://www.postgresql.org/docs/current/datatype-oid.html) has a different internal key. **Example:** A table with 4 indexes will have at least 5 internal keys, one for the table and one for each index. Additional associated relations, such as sequences or a TOAST table, also have their own keys. ## Encryption algorithm {#encryption-algorithm} `pg_tde` currently uses the following encryption algorithms: * `AES-128-CBC`, `AES-256-CBC` for encrypting database files; encrypted with internal keys * `AES-128-CTR`, `AES-256-CTR` for WAL encryption; encrypted with internal keys * `AES-128-GCM`, `AES-256-GCM` for encrypting internal keys; encrypted with the principal key ## Encryption workflow {#encryption-workflow} You can use `pg_tde` to encrypt entire databases or only selected tables. To support this without metadata changes, encrypted tables are labeled with the `tde_heap` access method marker. The `tde_heap` access method is functionally identical to the `heap` access method. This allows `pg_tde` to distinguish between encrypted (`tde_heap`) and non-encrypted (`heap`) tables. The initial decision about encryption is made using the `postgres` event trigger mechanism: * When the `tde_heap` clause is used for `CREATE TABLE` or `ALTER TABLE` statements, then the newly created data files are marked as encrypted * After this, the file operations encrypt or decrypt the data Subsequent decisions are done using a slightly modified Storage Manager (SMGR) API: * When a database file is re-created with a different ID as a result of a `TRUNCATE` or a `VACUUM FULL` command, the newly created file inherits the encryption information * The file is then either encrypted or left unencrypted based on that inheritance ## WAL encryption functionality {#wal-encryption-functionality} You can control WAL encryption globally via the [`pg_tde.wal_encrypt`](/docs/tde/upstream/variables/#pgtde-walencrypt) GUC variable, which requires a server restart. WAL keys also contain the [LSN ](https://www.postgresql.org/docs/17/wal-internals.html) of the first WAL write after key creation. This allows `pg_tde` to know which WAL ranges are encrypted or not and with which key. > [!NOTE] > See the [Configure WAL encryption](/docs/tde/upstream/wal-encryption/) chapter for more information. The setting only controls writes so that only WAL writes are encrypted when WAL encryption is enabled. This means that WAL files can contain both encrypted and unencrypted data, depending on what the status of this variable was when writing the data. `pg_tde` keeps track of the encryption status of WAL records using internal keys. When the server is restarted it writes a new internal key if WAL encryption is enabled, or if it is disabled and was previously enabled it writes a dummy key signaling that WAL encryption ended. With this information the WAL reader code can decide if a specific WAL record has to be decrypted or not and which key it should use to decrypt it. ## Encrypting other access methods {#encrypting-other-access-methods} Currently `pg_tde` only encrypts `heap` tables and other files such as indexes, TOAST tables, sequences that are related to the `heap` tables. Indexes include any kind of index that goes through the SMGR API, not just the built-in indexes in PostgreSQL. Other table access methods that use the SMGR API could also be encrypted. This requires adding a marker access method and extending the event triggers, using the same approach as with `heap` tables. ## Storage Manager (SMGR) API {#storage-manager-smgr-api} `pg_tde` relies on a slightly modified version of the SMGR API. These modifications include: * Making the API generally extensible, where extensions can inject custom code into the storage manager * Adding tracking information for files. When a new file is created for an existing relation, references to the existing file are also passed to the SMGR functions With these modifications, `pg_tde` implements an additional layer on top of the normal Magnetic Disk SMGR API: if the related table is encrypted, `pg_tde` encrypts a file before writing it to the disk and, similarly, decrypts it after reading when needed. ## WAL encryption {#wal-encryption} WAL encryption is implemented through a separate, server-wide mechanism that extends PostgreSQL WAL-related APIs. Similar to the SMGR integration, this relies on additional extensions to PostgreSQL core APIs to support encryption of WAL records. For configuration details, see [Configure WAL encryption](/docs/tde/upstream/wal-encryption/). [PG.CENTER edition](https://github.com/pgsty/doc.pg.center/blob/4410c32dc9186a22859008303f474b72a779f583/content/percona/architecture/encryption-architecture.md) · [Upstream source](https://github.com/percona/pg_tde/blob/5dd7a9e4e3599d88546f5de67ff0f4ef3fe51a9a/documentation/docs/architecture/encryption-architecture.md) --- Backlinks: - [Documentation errata](/docs/tde/upstream/site/errata/) ================ Source: https://mimus.pgsty.com/docs/tde/upstream/architecture/key-provider-management/index.md ================ # Key and key provider management > How key scope, provider storage, privileges, and key rotation work. --- LLMS index: [llms.txt](/llms.txt) --- > This is the Percona pg_tde 2.3.0 manual. For the paired build, backup tools and major upgrades, see [PG TDE on Mimus](/docs/tde/). `pg_tde` uses a hierarchy of principal and internal keys to encrypt database files. This chapter covers how to manage these keys, including rotation, regeneration, storage, and key provider configuration, so you can keep your encrypted data secure and accessible. ## Principal key rotation {#principal-key-rotation} You can rotate principal keys to comply with common policies and to handle situations with potentially exposed principal keys. Rotation means that `pg_tde` generates a new version of the principal key, and re-encrypts the associated internal keys with the new key. The old principal key is kept as is at the same location, because it may still be needed to decrypt backups or other databases. ## Internal key regeneration {#internal-key-regeneration} Internal keys for tables, indexes and other data files are generated once a file is created. There's no way to re-encrypt a file. There are workarounds for this, because operations that move the table data to a new file, such as `VACUUM FULL` or an `ALTER TABLE` that rewrites the file will create a new key for the new file, essentially rotating the internal key. This however means taking an exclusive lock on the table for the duration of the operation, which might not be desirable for huge tables. WAL internal keys are fixed once created. Every time the server (re)starts, a new WAL key is generated. If WAL encryption is enabled (using `pg_tde.wal_encrypt`), all WAL writes following the creation of the new key are encrypted with it until **another** key is generated at the next restart. This ensures that each WAL segment uses a consistent encryption key, without requiring you to manage key rotation manually. ## Internal key storage {#internal-key-storage} Internal keys and `pg_tde` metadata in general are kept in a single `$PGDATA/pg_tde` directory. This directory stores separate files for each database, such as: * Encrypted internal keys and internal key mapping to tables * Information about the key providers Also, the `$PGDATA/pg_tde` directory has a special global section marked with the OID `1664`, which includes the global key providers and global internal keys. The global section is used for WAL encryption. Specific databases can use the global section too, for scenarios where users configure individual principal keys for databases but use the same global key provider. For this purpose, you must enable the global provider inheritance. The global default principal key uses the special OID `1663`. ## Key providers (principal key storage) {#key-providers-principal-key-storage} In `pg_tde`, a Key Management System (KMS) is treated as an external key provider. Key providers store and serve the principal keys that `pg_tde` uses for encryption and decryption. When you configure a key provider, `pg_tde`: * Uploads new principal keys when they are created * Retrieves principal keys from the provider when needed for decryption (for example, at startup or restart) * Caches retrieved keys to reduce repeated lookups > [!NOTE] > Each key provider requires a detailed configuration, including the service address and authentication information. For a complete list of supported providers and their configuration steps, see the [Key management overview](/docs/tde/upstream/global-key-provider-configuration/overview/). ## Key provider management {#key-provider-management} Key provider configuration or location may change. For example, a service is moved to a new address or the principal key must be moved to a different key provider type. `pg_tde` supports both these scenarios enabling you to manage principal keys using simple [SQL functions](/docs/tde/upstream/functions/#key-provider-management). In certain cases you can't use SQL functions to manage key providers. For example, if the key provider changed while the server wasn't running and is therefore unaware of these changes. The startup can fail if it needs to access the encryption keys. For such situations, `pg_tde` also provides [command line tools](/docs/tde/upstream/command-line-tools/cli-tools/) to recover the database. ## Sensitive key provider information {#sensitive-key-provider-information} > [!IMPORTANT] > Authentication details for key providers are sensitive and must be protected. > Do not store these credentials in the `$PGDATA` directory alongside the database. Instead, ensure they are stored in a secure location with strict file system permissions to prevent unauthorized access. [PG.CENTER edition](https://github.com/pgsty/doc.pg.center/blob/4410c32dc9186a22859008303f474b72a779f583/content/percona/architecture/key-provider-management.md) · [Upstream source](https://github.com/percona/pg_tde/blob/5dd7a9e4e3599d88546f5de67ff0f4ef3fe51a9a/documentation/docs/architecture/key-provider-management.md) ================ Source: https://mimus.pgsty.com/docs/tde/upstream/how-to/index.md ================ # Operations > Operational procedures for backup, restore, upgrades, enforcement, and multi-tenancy. --- LLMS index: [llms.txt](/llms.txt) --- > This is the Percona pg_tde 2.3.0 manual. For the paired build, backup tools and major upgrades, see [PG TDE on Mimus](/docs/tde/). [PG.CENTER edition](https://github.com/pgsty/doc.pg.center/blob/4410c32dc9186a22859008303f474b72a779f583/content/percona/how-to/_index.md) · [Upstream source](https://github.com/percona/pg_tde/tree/5dd7a9e4e3599d88546f5de67ff0f4ef3fe51a9a) --- Section pages: - [Encryption enforcement](/docs/tde/upstream/how-to/enforcement/): Require new tables to use encryption at the server, database, role, or session level. - [Configure multi-tenancy](/docs/tde/upstream/how-to/multi-tenant-setup/): Separate database keys and privileges for tenants sharing a PostgreSQL cluster. - [Backup with WAL encryption enabled](/docs/tde/upstream/how-to/backup-wal-enabled/): Back up an encrypted cluster and handle WAL with pgBackRest and pg_tde tools. - [Restore encrypted backups](/docs/tde/upstream/how-to/restore-backups/): Restore encrypted data while retaining access to keys and required metadata. - [Upgrade pg_tde](/docs/tde/upstream/how-to/upgrade/): Plan extension upgrades and major PostgreSQL upgrades for encrypted clusters. - [Remove encryption from an encrypted table](/docs/tde/upstream/how-to/decrypt/): Rewrite a tde_heap table with the standard heap access method. - [Uninstall pg_tde](/docs/tde/upstream/how-to/uninstall/): Remove encryption dependencies before uninstalling the extension and packages. --- Backlinks: - [Percona pg_tde 2.3.0](/docs/tde/upstream/) ================ Source: https://mimus.pgsty.com/docs/tde/upstream/how-to/enforcement/index.md ================ # Encryption enforcement > Require new tables to use encryption at the server, database, role, or session level. --- LLMS index: [llms.txt](/llms.txt) --- > This is the Percona pg_tde 2.3.0 manual. For the paired build, backup tools and major upgrades, see [PG TDE on Mimus](/docs/tde/). For `pg_tde`, encryption enforcement ensures that only encrypted storage is allowed for specific operations, tables, or the entire database. It prevents the accidental creation of unencrypted tables or indexes in environments where encryption is required for compliance, security, or policy enforcement. ## What does enforcement do? {#what-does-enforcement-do} When enabled, encryption enforcement: * Prevents creation of unencrypted tables or indexes * Enforces consistent encryption usage across tenants, databases, or users * Can be scoped globally, per database, or per role ## Enforce encryption usage {#enforce-encryption-usage} Use the following techniques to enforce the secure use of `pg_tde`. ### 1. Enforce encryption across the server {#1-enforce-encryption-across-the-server} To enforce encryption cluster-wide, set the [`pg_tde.enforce_encryption`](/docs/tde/upstream/variables/#pgtde-enforceencryption) variable in `postgresql.conf`: ```ini pg_tde.enforce_encryption = on ``` > [!NOTE] > **Only** superusers can set or change this variable. This ensures that no user, including superusers, can create unencrypted tables. Superusers can however explicitly [override the variable in their session](#override-enforcement-for-trusted-sessions). ### 2. Enforce encryption for a specific database {#2-enforce-encryption-for-a-specific-database} To apply encryption enforcement only within a specific database, run: ```sql ALTER DATABASE example_db SET pg_tde.enforce_encryption = on; ``` This ensures encryption is enforced **only** when connected to that database. ### 3. Enforce encryption for a specific user {#3-enforce-encryption-for-a-specific-user} You can also enforce encryption on a per-user basis, run: ```sql ALTER USER example_user SET pg_tde.enforce_encryption = on; ``` This ensures that the user `example_user` cannot create unencrypted tables, regardless of which database they connect to. ### Override enforcement for trusted sessions {#override-enforcement-for-trusted-sessions} Superusers can override the variable at the session level: ```sql SET pg_tde.enforce_encryption = off; ``` This allows temporary creation of unencrypted tables in special cases, such as: * Loading trusted, public reference datasets * Benchmarking and test environments * Migration staging before re-encryption > [!NOTE] > While superusers can disable enforcement in their session, they must do so explicitly. Enforcement defaults remain active to protect from accidental misconfiguration. [PG.CENTER edition](https://github.com/pgsty/doc.pg.center/blob/4410c32dc9186a22859008303f474b72a779f583/content/percona/how-to/enforcement.md) · [Upstream source](https://github.com/percona/pg_tde/blob/5dd7a9e4e3599d88546f5de67ff0f4ef3fe51a9a/documentation/docs/how-to/enforcement.md) --- Backlinks: - [GUC settings](/docs/tde/upstream/variables/) ================ Source: https://mimus.pgsty.com/docs/tde/upstream/how-to/multi-tenant-setup/index.md ================ # Configure multi-tenancy > Separate database keys and privileges for tenants sharing a PostgreSQL cluster. --- LLMS index: [llms.txt](/llms.txt) --- > This is the Percona pg_tde 2.3.0 manual. For the paired build, backup tools and major upgrades, see [PG TDE on Mimus](/docs/tde/). The steps below describe how to set up multi-tenancy with `pg_tde`. Multi-tenancy allows you to encrypt different databases with different keys. This provides granular control over data and enables you to introduce different security policies and access controls for each database so that only authorized users of specific databases have access to the data. If you don't need multi-tenancy, use the global key provider. See the configuration steps from the [Configure pg_tde ](/docs/tde/upstream/setup/) section. For how to enable WAL encryption, refer to the [Configure WAL Encryption ](/docs/tde/upstream/wal-encryption/) section. ## Considerations {#considerations} You can use external key providers to manage encryption keys. The recommended approach is to use the Key Management Store (KMS). For more information, see [Configure Key Management (KMS) ](/docs/tde/upstream/global-key-provider-configuration/overview/). > [!NOTE] > If no error is reported when running the commands below, the operation completed successfully. ## Enable extension {#enable-extension} Load the `pg_tde` at startup time. The extension requires additional shared memory; therefore, add the `pg_tde` value for the `shared_preload_libraries` parameter and restart the `postgresql` cluster. 1. Use the [ALTER SYSTEM ](https://www.postgresql.org/docs/current/sql-altersystem.html) command from `psql` terminal to modify the `shared_preload_libraries` parameter. This requires superuser privileges. ```sql ALTER SYSTEM SET shared_preload_libraries = 'pg_tde'; ``` 2. Start or restart the `postgresql` cluster to apply the changes. * On Debian and Ubuntu: ```sh sudo systemctl restart postgresql-17 ``` * On RHEL and derivatives ```sh sudo systemctl restart postgresql-17 ``` 3. Create the extension using the [CREATE EXTENSION ](https://www.postgresql.org/docs/current/sql-createextension.html) command. You must have the privileges of a superuser or a database owner to use this command. Connect to `psql` as a superuser for a database and run the following command: ```sql CREATE EXTENSION pg_tde; ``` The `pg_tde` extension is created for the currently used database. To enable data encryption in other databases, you must explicitly run the `CREATE EXTENSION` command against them. > [!TIP] > > You can have the `pg_tde` extension automatically enabled for every newly created database. Modify the template `template1` database as follows: > > ```sh > psql -d template1 -c 'CREATE EXTENSION pg_tde;' > ``` ## Key provider configuration {#key-provider-configuration} You must do these steps for every database where you have created the extension. For more information on configurations, please see the [Configure Key Management (KMS) ](/docs/tde/upstream/global-key-provider-configuration/overview/) topic. 1. Set up a key provider. **With KMIP server** The KMIP server setup is out of scope of this document. Make sure you have obtained the root certificate for the KMIP server and the keypair for the client. The client key needs permissions to create / read keys on the server. Find the [configuration guidelines for the HashiCorp Vault Enterprise KMIP Secrets Engine ](https://developer.hashicorp.com/vault/tutorials/enterprise/kmip-engine). For testing purposes, you can use the Eviden KMS server which enables you to set up required certificates. To use a real KMIP server, make sure to obtain the valid certificates issued by the key management appliance. ```sql SELECT pg_tde_add_database_key_provider_kmip( 'provider-name', 'kmip-addr', `port`, '/path_to/client_cert.pem', '/path_to/client_key.pem', '/path_to/server_certificate.pem' ); ``` where: * `provider-name` is the name of the provider. You can specify any name, it's for you to identify the provider. * `kmip-addr` is the IP address of a domain name of the KMIP server * `port` is the port to communicate with the KMIP server. Typically used port is 5696. * `server-certificate` is the path to the certificate file for the KMIP server. * `client-cert` is the path to the client certificate. * `client-key` is the path to the client key. **Warning:** This example is for testing purposes only: ```sql SELECT pg_tde_add_database_key_provider_kmip( 'kmip', '127.0.0.1', 5696, '/tmp/client_cert_jane_doe.pem', '/tmp/client_key_jane_doe.pem', '/tmp/server_certificate.pem' ); ``` **With HashiCorp Vault** The Vault server setup is out of scope of this document. ```sql SELECT pg_tde_add_database_key_provider_vault_v2( 'provider-name', 'url', 'mount', 'secret_token_path', 'ca_path' ); ``` where: * `url` is the URL of the Vault server * `mount` is the mount point where the keyring should store the keys * `secret_token_path` is a path to the file that contains an access token with read and write access to the above mount point * [optional] `ca_path` is the path of the CA file used for SSL verification **Warning:** This example is for testing purposes only: ```sql SELECT pg_tde_add_database_key_provider_file_vault_v2( 'my-vault', 'http://vault.vault.svc.cluster.local:8200', 'secret/data', 'hvs.zPuyktykA...example...ewUEnIRVaKoBzs2', NULL ); ``` **With a keyring file \(not recommended\)** This setup is intended for development and stores the keys unencrypted in the specified data file. ```sql SELECT pg_tde_add_database_key_provider_file( 'provider-name', '/path/to/the/keyring/data.file' ); ``` **Warning:** This example is for testing purposes only: ```sql SELECT pg_tde_add_database_key_provider_file( 'file-keyring', '/tmp/pg_tde_test_local_keyring.per' ); ``` 2. Create a key ```sql SELECT pg_tde_create_key_using_database_key_provider( 'name-of-the-key', 'provider-name' ); ``` where: * `name-of-the-key` is the name of the principal key. You will use this name to identify the key. * `provider-name` is the name of the key provider you added before. The principal key is associated with this provider and it is the location where it is stored and fetched from. **Warning:** This example is for testing purposes only: ```sql SELECT pg_tde_create_key_using_database_key_provider( 'test-db-master-key', 'file-vault' ); ``` > [!NOTE] > The key is auto-generated. 3. Use the key as principal key ```sql SELECT pg_tde_set_key_using_database_key_provider( 'name-of-the-key', 'provider-name' ); ``` where: * `name-of-the-key` is the name of the principal key. You will use this name to identify the key. * `provider-name` is the name of the key provider you added before. The principal key will be associated with this provider. **Warning:** This example is for testing purposes only: ```sql SELECT pg_tde_set_key_using_database_key_provider( 'test-db-master-key', 'file-vault' ); ``` [PG.CENTER edition](https://github.com/pgsty/doc.pg.center/blob/4410c32dc9186a22859008303f474b72a779f583/content/percona/how-to/multi-tenant-setup.md) · [Upstream source](https://github.com/percona/pg_tde/blob/5dd7a9e4e3599d88546f5de67ff0f4ef3fe51a9a/documentation/docs/how-to/multi-tenant-setup.md) --- Backlinks: - [FAQ](/docs/tde/upstream/faq/) - [Features](/docs/tde/upstream/features/) - [Load the extension](/docs/tde/upstream/setup/) ================ Source: https://mimus.pgsty.com/docs/tde/upstream/how-to/backup-wal-enabled/index.md ================ # Backup with WAL encryption enabled > Back up an encrypted cluster and handle WAL with pgBackRest and pg_tde tools. --- LLMS index: [llms.txt](/llms.txt) --- > For Mimus, choose the backup client by WAL key history and use the client paired with the kernel. See the tested physical backup and restore sequence. [Mimus procedure](/docs/tde/recovery/) > [!DANGER] > Do not rotate encryption keys while a backup is running. This may result in an inconsistent backup and restore failure. This applies to all backup tools. > > For more details, see [Limitations of pg_tde](/docs/tde/upstream/index/tde-limitations/#limitations-when-using-pgtde). To create a backup with WAL encryption enabled: 1. Copy the `pg_tde` directory from the source server’s data directory, for example `/var/lib/postgresql/data/pg_tde/`, including the `wal_keys` and `1664_providers` files, to the backup destination directory where `pg_tde_basebackup` will write the backup. Also copy any external files referenced by your providers configuration (such as certificate or key files) into the same relative paths under the backup destination, so that they are located and validated by `pg_tde_basebackup -E`. 2. Run: ```bash pg_tde_basebackup -D /path/to/backup -E [aes_128|aes_256] ``` Where: - `-D /path/to/backup` specifies the backup location where you have to copy `pg_tde`. - `-E` (or `--encrypt-wal`) enables WAL encryption and validates that the copied `pg_tde` and provider files are present and that the server key is accessible (required). The `-E` option accepts a cipher argument. The currently supported values are `aes_128` and `aes_256`. If `-E` is not specified, `pg_tde_basebackup` attempts to determine the cipher from the server's key. If no cipher can be determined, `pg_tde_basebackup` defaults to `aes_128`. > [!NOTE] > - The `-E` flag only works with the `-X stream` option (default). It is not compatible with `-X none` or `-X fetch`. For more information, see [the backup method compatibility with WAL encryption](#backup-method-compatibility-with-wal-encryption). > - The `-E` flag is only supported with the plain output format (`-F p`). It cannot be used with the tar output format (`-F t`). ## Key rotation during backups {#key-rotation-during-backups} > [!DANGER] > Do not rotate encryption keys while a backup is in progress. This applies to all backup tools. > > Backups created during key rotation may fail to start during WAL replay and may lead to corruption of encrypted data (tables, indexes, and other relations). > > For example, you may see errors such as: > > ```sql > FATAL: failed to retrieve principal key "database_keyXXXX" from key provider "providerYYYY" > CONTEXT: WAL redo at ... ROTATE_PRINCIPAL_KEY ... > ``` > > To ensure standby recoverability, plan key rotations outside backup windows or take a new full backup after rotation completes. ## Restore a backup created with WAL encryption {#restore-a-backup-created-with-wal-encryption} When you want to restore a backup created with `pg_tde_basebackup -E`: 1. Ensure all external files referenced by your providers configuration (such as certificates or key files) are also present and accessible at the same relative paths. 2. Start PostgreSQL with the restored data directory. ## Backup method compatibility with WAL encryption {#backup-method-compatibility-with-wal-encryption} Tar format (`-F t`): * Works with `-X fetch`. * Does not support `-X stream` when WAL encryption is enabled. Using `pg_tde_basebackup -F t -X stream` will create a broken replica. Streaming mode (`-X stream`): * **Must** specify `-E` (`--encrypt-wal`). * Without `-E`, backups may contain decrypted WAL while `wal_encryption=on` remains in `postgresql.conf` and `pg_tde/wal_keys` are copied. This leads to **startup failures and compromised data in the backup**. Fetch mode (`-X fetch`): * Compatible with encrypted WAL without requiring any additional flags. None (`-X none`): * Excludes WAL from the backup and is unaffected by WAL encryption. > [!NOTE] > If the source server has `pg_tde/wal_keys`, running `pg_tde_basebackup` with `-X none` or `-X fetch` produces warnings such as: > > ```sql > pg_tde_basebackup: warning: the source has WAL keys, but no WAL encryption configured for the target backups > pg_tde_basebackup: detail: This may lead to exposed data and broken backup > pg_tde_basebackup: hint: Run pg_tde_basebackup with -E to encrypt streamed WAL > ``` > > You can safely ignore the warnings with `-X none` or `-X fetch`, since no WAL streaming occurs. [PG.CENTER edition](https://github.com/pgsty/doc.pg.center/blob/4410c32dc9186a22859008303f474b72a779f583/content/percona/how-to/backup-wal-enabled.md) · [Upstream source](https://github.com/percona/pg_tde/blob/5dd7a9e4e3599d88546f5de67ff0f4ef3fe51a9a/documentation/docs/how-to/backup-wal-enabled.md) --- Backlinks: - [Back up, restore and migrate](/docs/tde/recovery/) - [pg_tde 2.2.2: Vault Enterprise KMIP and faster WAL encryption](/docs/tde/upstream/blog/release/2.2.2/) - [Tool overview](/docs/tde/upstream/command-line-tools/cli-tools/) - [Upgrade pg_tde](/docs/tde/upstream/how-to/upgrade/) - [Limitations](/docs/tde/upstream/index/tde-limitations/) - [Operational impact](/docs/tde/upstream/index/what-tde-impacts/) - [2.0.0](/docs/tde/upstream/release-notes/release-notes-v2.0/) - [2.2.0](/docs/tde/upstream/release-notes/release-notes-v2.2.0/) ================ Source: https://mimus.pgsty.com/docs/tde/upstream/how-to/restore-backups/index.md ================ # Restore encrypted backups > Restore encrypted data while retaining access to keys and required metadata. --- LLMS index: [llms.txt](/llms.txt) --- > For Mimus, restore the matching kernel, startup libraries, provider metadata and historical keys along with the backup. [Mimus procedure](/docs/tde/recovery/) To restore an encrypted backup created with an earlier key, ensure the key is still available in your Key Management System (KMS). The backup remains **encrypted** on disk, `pg_tde` uses the correct key to transparently access the data. ## How pg_tde uses old keys to load backups {#how-pgtde-uses-old-keys-to-load-backups} * **KMS**: stores the principal key(s) that were active when the backup was made. * **Encrypted backup**: contains data encrypted with the key available at that time. * **Current server**: `pg_tde` automatically loads the backup if the key is accessible through the KMS. The table (internal) keys are stored within the backup. At runtime, `pg_tde` retrieves the principal key(s) from the configured KMS and uses them to decrypt the internal keys, enabling access to the encrypted table data. > [!NOTE] > If the required key(s) get deleted or are missing, the backup **cannot** be read. > > If the key(s) still exists but the KMS configuration has changed, you can use [`pg_tde_change_key_provider`](/docs/tde/upstream/command-line-tools/pg-tde-change-key-provider/) to update the configuration. > > However, if the key(s) got deleted from all accessible KMS sources, the encrypted backup is **unrecoverable**. [PG.CENTER edition](https://github.com/pgsty/doc.pg.center/blob/4410c32dc9186a22859008303f474b72a779f583/content/percona/how-to/restore-backups.md) · [Upstream source](https://github.com/percona/pg_tde/blob/5dd7a9e4e3599d88546f5de67ff0f4ef3fe51a9a/documentation/docs/how-to/restore-backups.md) --- Backlinks: - [Migration and operations](/docs/mssql/operations/) - [Operational impact](/docs/tde/upstream/index/what-tde-impacts/) ================ Source: https://mimus.pgsty.com/docs/tde/upstream/how-to/upgrade/index.md ================ # Upgrade pg_tde > Plan extension upgrades and major PostgreSQL upgrades for encrypted clusters. --- LLMS index: [llms.txt](/llms.txt) --- > Percona’s package upgrade steps apply to Percona PostgreSQL. For a major upgrade of a TDE-marked Mimus cluster use [logical dump and restore](/docs/tde/recovery/#upgrade). The version of `pg_tde` available to you depends on your version of Percona Distribution for PostgreSQL. To use a newer `pg_tde` release, first ensure that your Percona Distribution for PostgreSQL version includes it. This document describes upgrading the `pg_tde` extension within the same PostgreSQL major version. For PostgreSQL major version upgrades on clusters that use `pg_tde`, use [pg_tde_upgrade](/docs/tde/upstream/command-line-tools/pg-tde-upgrade/). ## Before you start {#before-you-start} > [!NOTE] > `pg_tde` 2.2.0 is not compatible with Percona Distribution for PostgreSQL older than 17.10 or 18.4. Upgrade your distribution first before upgrading `pg_tde`. > [!WARNING] > Using `pg_upgrade` on an encrypted cluster is not supported and will result in data corruption. The server may start successfully but queries against encrypted tables will fail. ## Procedure {#procedure} 1. Take a full [backup before upgrading](/docs/tde/upstream/how-to/backup-wal-enabled/). 2. Upgrade the `pg_tde` package via your package manager. 3. Restart the `postgresql` service. 4. Connect to each database where `pg_tde` is installed and run: ```sql ALTER EXTENSION pg_tde UPDATE; ``` > [!NOTE] > The catalog version of `pg_tde` may not change between patch releases. You can run `ALTER EXTENSION pg_tde UPDATE` safely regardless. 5. Verify the upgrade: ```sql SELECT extname, extversion FROM pg_extension WHERE extname = 'pg_tde'; SELECT pg_tde_version(); ``` [PG.CENTER edition](https://github.com/pgsty/doc.pg.center/blob/4410c32dc9186a22859008303f474b72a779f583/content/percona/how-to/upgrade.md) · [Upstream source](https://github.com/percona/pg_tde/blob/5dd7a9e4e3599d88546f5de67ff0f4ef3fe51a9a/documentation/docs/how-to/upgrade.md) --- Backlinks: - [Major upgrade](/docs/tde/upstream/command-line-tools/pg-tde-upgrade/) ================ Source: https://mimus.pgsty.com/docs/tde/upstream/how-to/decrypt/index.md ================ # Remove encryption from an encrypted table > Rewrite a tde_heap table with the standard heap access method. --- LLMS index: [llms.txt](/llms.txt) --- > This is the Percona pg_tde 2.3.0 manual. For the paired build, backup tools and major upgrades, see [PG TDE on Mimus](/docs/tde/). ## Method 1. Change the access method {#method-1-change-the-access-method} If you encrypted a table with the `tde_heap` access method and need to remove the encryption from it, run the following command against the desired table (`mytable` in the example below): ```sql ALTER TABLE mytable SET ACCESS METHOD heap; ``` Note that the `SET ACCESS METHOD` command drops hint bits and this may affect performance. Running a plain `SELECT count(*)` or `VACUUM` command on the entire table will check every tuple for visibility and set its hint bits. Therefore, after executing the `ALTER TABLE` command, run a simple `count(*)` on your tables: ```sql SELECT count(*) FROM mytable; ``` Check that the table is not encrypted: ```sql SELECT pg_tde_is_encrypted('mytable'); ``` The output returns `f` meaning that the table is no longer encrypted. ## Method 2. Create a new not encrypted table on the base of the encrypted one {#method-2-create-a-new-not-encrypted-table-on-the-base-of-the-encrypted-one} Alternatively, you can create a new not encrypted table with the same structure and data as the initial table. For example, the original encrypted table is `EncryptedCustomers`. Use the following command to create a new table `Customers`: ```sql CREATE TABLE Customers AS SELECT * FROM EncryptedCustomers; ``` The new table `Customers` inherits the structure and the data from `EncryptedCustomers`. (Optional) If you no longer need the `EncryptedCustomers` table, you can delete it. ```sql DROP TABLE EncryptedCustomers; ``` [PG.CENTER edition](https://github.com/pgsty/doc.pg.center/blob/4410c32dc9186a22859008303f474b72a779f583/content/percona/how-to/decrypt.md) · [Upstream source](https://github.com/percona/pg_tde/blob/5dd7a9e4e3599d88546f5de67ff0f4ef3fe51a9a/documentation/docs/how-to/decrypt.md) --- Backlinks: - [Verify encryption](/docs/tde/upstream/test/) ================ Source: https://mimus.pgsty.com/docs/tde/upstream/how-to/uninstall/index.md ================ # Uninstall pg_tde > Remove encryption dependencies before uninstalling the extension and packages. --- LLMS index: [llms.txt](/llms.txt) --- > Mimus records TDE in the data directory. Retain the matching preload, tools and historical keys for recovery, including after dropping the SQL extension. To retire the dependency, migrate into a fresh cluster. [Mimus procedure](/docs/tde/recovery/) If you no longer wish to use Transparent Data Encryption (TDE) in your deployment, you can remove the `pg_tde` extension. To proceed, you must have one of the following privileges: - Superuser privileges (to remove the extension globally), or - Database owner privileges (to remove it from a specific database only) To uninstall `pg_tde`, follow the steps below. ## Step 1. Remove `pg_tde` from all databases {#step-1-remove-pgtde-from-all-databases} Before uninstalling, you must remove the extension from every database where it is loaded. If `pg_tde` was installed in templates, new databases inherit it. You must drop it from the templates first or future restores/creates will break. a. Rewrite encrypted tables: To rewrite an encrypted table back to its default storage method: ```sql ALTER TABLE SET ACCESS METHOD heap; ``` b. Remove the extension once all encrypted tables have been rewritten or dropped: ```sql DROP EXTENSION pg_tde; ``` > [!NOTE] > If there are any encrypted objects that were not previously decrypted or deleted, this command will fail and you have to follow the steps above for these objects. > > Repeat step 1 for every database in your cluster. ## Step 2. Turn off WAL encryption {#step-2-turn-off-wal-encryption} If you are using WAL encryption, you need to **turn it off** before you uninstall the `pg_tde` library: a. Run: ```sql ALTER SYSTEM SET pg_tde.wal_encrypt = off; ``` b. Restart the PostgreSQL cluster to apply the changes: - On Debian and Ubuntu: ```sh sudo systemctl restart postgresql ``` - On RHEL and derivatives: ```sh sudo systemctl restart postgresql-(pg-version) ``` ## Step 3. Uninstall the `pg_tde` shared library {#step-3-uninstall-the-pgtde-shared-library} > [!WARNING] > This process removes the extension, but **does not** decrypt data automatically. Only uninstall the shared library after all encrypted data **has been removed or decrypted** and WAL encryption **has been disabled**. > [!NOTE] > Encrypted WAL pages **will not be decrypted**, so any postgres cluster needing to read them will need the `pg_tde` library loaded, and the WAL encryption keys available and in use. At this point, the shared library is still loaded but no longer active. To fully uninstall `pg_tde`, complete the steps below. a. Run `SHOW shared_preload_libraries` to view the current configuration of preloaded libraries. For example: ```sql postgres=# SHOW shared_preload_libraries; shared_preload_libraries ----------------------------------------- pg_stat_statements,pg_tde,auto_explain (1 row) postgres=# ``` b. Remove `pg_tde` from the list and apply the new setting using `ALTER SYSTEM SET shared_preload_libraries=`. For example: ```sql postgres=# ALTER SYSTEM SET shared_preload_libraries=pg_stat_statements,auto_explain; ALTER SYSTEM postgres=# ``` > [!NOTE] > Your list of libraries will most likely be different than the above example. Take care not to remove other required extensions. Only delete `pg_tde` from the list. > > If `pg_tde` is the only shared library in the list, and it was set via `postgresql.conf` you cannot disable it using the `ALTER SYSTEM SET ...` command. Instead: > > 1. Remove the `shared_preload_libraries` line from `postgresql.conf` > 2. Run `ALTER SYSTEM RESET shared_preload_libraries;` c. Restart the `postgresql` cluster to apply the changes: - On Debian and Ubuntu: ```sh sudo systemctl restart postgresql ``` - On RHEL and derivatives: ```sh sudo systemctl restart postgresql-(pg-version) ``` > [!NOTE] > The service name may differ depending on your distribution and PostgreSQL version.nod ## Step 4. (Optional but recommended) Clean up configuration {#step-4-optional-but-recommended-clean-up-configuration} At this point it is safe to remove any configuration related to `pg_tde` from `postgresql.conf` and `postgresql.auto.conf`. Look for any configuration parameters prefixed with `pg_tde.` and remove or comment them out, as needed. ## Troubleshooting: PANIC checkpoint not found on restart {#troubleshooting-panic-checkpoint-not-found-on-restart} This can happen if WAL encryption was not properly disabled before removing `pg_tde` from `shared_preload_libraries`, when the PostgreSQL server was not restarted after disabling WAL encryption (see step 3.c). You might see this when restarting the PostgreSQL cluster: ```ini 2025-04-01 17:12:50.607 CEST [496385] PANIC: could not locate a valid checkpoint record at 0/17B2580 ``` This error means PostgreSQL is trying to read encrypted WAL without `pg_tde` loaded. To resolve it follow these steps: 1. Re-add `pg_tde` to `shared_preload_libraries` 2. Restart the PostgreSQL cluster 3. Follow the [instructions for turning off WAL encryption](#step-2-turn-off-wal-encryption) before uninstalling the shared library again > [!NOTE] > Two restarts are required to uninstall properly if WAL encryption was enabled: > > - First to disable WAL encryption > - Second to remove the `pg_tde` library [PG.CENTER edition](https://github.com/pgsty/doc.pg.center/blob/4410c32dc9186a22859008303f474b72a779f583/content/percona/how-to/uninstall.md) · [Upstream source](https://github.com/percona/pg_tde/blob/5dd7a9e4e3599d88546f5de67ff0f4ef3fe51a9a/documentation/docs/how-to/uninstall.md) --- Backlinks: - [RC 1](/docs/tde/upstream/release-notes/rc/) - [RC 2](/docs/tde/upstream/release-notes/rc2/) - [2.0.0](/docs/tde/upstream/release-notes/release-notes-v2.0/) ================ Source: https://mimus.pgsty.com/docs/tde/upstream/wal-encryption/index.md ================ # Configure WAL encryption > Create and assign the server principal key, then enable encrypted WAL writes. --- LLMS index: [llms.txt](/llms.txt) --- > This is the Percona pg_tde 2.3.0 manual. For the paired build, backup tools and major upgrades, see [PG TDE on Mimus](/docs/tde/). WAL encryption requires a principal key. You can satisfy this requirement in one of the following ways: > [!WARNING] WAL archiving and recovery requirements > > A deployment with WAL encryption is not supported unless you use both of the following tools for WAL archiving and recovery: > > * [`pg_tde_archive_decrypt`](/docs/tde/upstream/command-line-tools/pg-tde-archive-decrypt/) in `archive_command` > * [`pg_tde_restore_encrypt`](/docs/tde/upstream/command-line-tools/pg-tde-restore-encrypt/) in `restore_command` > > If you use pgBackRest, you must also disable its asynchronous archiving, WAL header checks, and page checksum validation. Add these settings to the applicable pgBackRest configuration section: > > ```ini > archive-async=n > archive-header-check=n > checksum-page=n > ``` ## Option 1: Use the default principal key {#option-1-use-the-default-principal-key} If a default principal key is already configured for the server, WAL encryption uses it automatically. No additional server key configuration is required. If you have not yet configured a default principal key, see [Default Principal Key configuration](/docs/tde/upstream/global-key-provider-configuration/set-principal-key/). ## Option 2: Configure a dedicated server principal key for WAL {#option-2-configure-a-dedicated-server-principal-key-for-wal} > [!NOTE] > For a comprehensive list of supported `pg_tde` WAL encryption tools see [Limitations of pg_tde](/docs/tde/upstream/index/tde-limitations/). 1. Create the `pg_tde` extension if it does not exist: ```sql CREATE EXTENSION IF NOT EXISTS pg_tde; ``` 2. Configure a global key provider Before creating the server (principal) key for WAL encryption, you must first configure a global key provider. See [Key management overview](/docs/tde/upstream/global-key-provider-configuration/overview/) for detailed instructions on configuring supported key providers. 3. Create the server (principal) key using the global key provider The server key (also referred to as the principal key) is the key used by PostgreSQL to encrypt WAL data. See [pg_tde_create_key_using_global_key_provider](/docs/tde/upstream/functions/#pgtdecreatekeyusingglobalkeyprovider) for more detailed instructions. 4. Set the server (principal) key This step sets the previously created server (principal) key as the active key used by PostgreSQL for WAL encryption. See [pg_tde_set_server_key_using_global_key_provider](/docs/tde/upstream/functions/#pgtdesetserverkeyusingglobalkeyprovider) for more detailed instructions. 5. Enable WAL encryption using the `ALTER SYSTEM` command. You need the privileges of the superuser to run this command: ```sql ALTER SYSTEM SET pg_tde.wal_encrypt = on; ``` 6. Restart the server to apply the changes. * On Debian and Ubuntu: ```sh sudo systemctl restart postgresql ``` * On RHEL and derivatives ```sh sudo systemctl restart postgresql- ``` 7. (Optional) Verify that WAL encryption is enabled: ```sql SHOW pg_tde.wal_encrypt; ``` Now WAL files start to be encrypted for both encrypted and unencrypted tables. For more technical references related to architecture, variables or functions, see: [Technical Reference](/docs/tde/upstream/advanced-topics/tech-reference/) 💬 Need help customizing this for your infrastructure? [Contact Percona support ](/docs/tde/upstream/get-help/) [PG.CENTER edition](https://github.com/pgsty/doc.pg.center/blob/4410c32dc9186a22859008303f474b72a779f583/content/percona/wal-encryption.md) · [Upstream source](https://github.com/percona/pg_tde/blob/5dd7a9e4e3599d88546f5de67ff0f4ef3fe51a9a/documentation/docs/wal-encryption.md) --- Backlinks: - [Encryption architecture](/docs/tde/upstream/architecture/encryption-architecture/) - [A production checklist for pg_tde](/docs/tde/upstream/blog/guide/production-checklist/) - [Local keyring](/docs/tde/upstream/global-key-provider-configuration/keyring/) - [Configure multi-tenancy](/docs/tde/upstream/how-to/multi-tenant-setup/) - [Get started](/docs/tde/upstream/install/) - [2.1.1](/docs/tde/upstream/release-notes/release-notes-v2.1.1/) - [Verify encryption](/docs/tde/upstream/test/) - [GUC settings](/docs/tde/upstream/variables/) ================ Source: https://mimus.pgsty.com/docs/tde/upstream/replication/index.md ================ # Streaming replication with tde_heap > Prepare keys, roles, and encrypted base backups for a physical streaming replica. --- LLMS index: [llms.txt](/llms.txt) --- > This is the Percona pg_tde 2.3.0 manual. For the paired build, backup tools and major upgrades, see [PG TDE on Mimus](/docs/tde/). > [!NOTE] Editorial correction > Creating a key and assigning the server key are separate operations. See [site errata](/docs/tde/upstream/site/errata/). This section outlines how to set up PostgreSQL streaming replication when the `pg_tde` extension, specifically the [`tde_heap`](/docs/tde/upstream/index/table-access-method/) access method, is enabled on the primary server. Before you begin, ensure you have followed the [`pg_tde` setup instructions](/docs/tde/upstream/setup/). > [!NOTE] > You do **not** need to run `CREATE EXTENSION` on the standby. It will be replicated automatically. ## 1. Configure the Primary {#1-configure-the-primary} ### Create a principal key {#create-a-principal-key} First create a key on the configured global provider using `pg_tde_create_key_using_global_key_provider`. Then assign it as the server key with [`pg_tde_set_server_key_using_global_key_provider`](/docs/tde/upstream/functions/#pgtdesetserverkeyusingglobalkeyprovider). ### Create the replication role {#create-the-replication-role} Create a replication role on the primary: ```sql CREATE ROLE example_replicator WITH REPLICATION LOGIN PASSWORD 'example_password'; ``` ### Configure pg_hba.conf {#configure-pghba-conf} To allow the replica to connect to the primary server, add the following line in `pg_hba.conf`: ```conf host replication example_replicator standby_ip/32 scram-sha-256 ``` Ensure that it is placed before the other host rules for replication and then **reload** the configuration: ```sql SELECT pg_reload_conf(); ``` ## 2. Configure the Standby {#2-configure-the-standby} ### Perform a database backup {#perform-a-database-backup} Run the base backup from your standby machine to pull the encrypted base backup: ```bash export PGPASSWORD='example_password' pg_tde_basebackup \ -h primary_ip \ -D /var/lib/pgsql/data \ -U example_replicator \ --wal-method=stream \ --slot=tde_slot \ -C \ -c fast \ -v -P ``` ### Configure postgresql.conf {#configure-postgresql-conf} After the base backup completes, add the following line to the standby's `postgresql.conf` file: ```ini shared_preload_libraries = 'pg_tde' ``` ## 3. Start and validate replication {#3-start-and-validate-replication} Assuming that the primary and the standby are running on separate hosts, start the PostgreSQL service: ```bash sudo systemctl start postgresql ``` > [!WARNING] Key management consistency **required** for replication > > If you're using a KMS provider, such as Vault or KMIP, make sure that both the primary and the standby have access to the **same** key management configuration, and that the paths to the configuration files are identical on both systems. > > For example: > > - If you configure Vault with a secret path: `/path/to/secret.file`, then that file **must** exist at the same path on both the primary and the standby. > - If you use the `keyring_file` provider, be aware that it stores key material in a local file and it is **not designed** for shared or concurrent use across multiple servers. It is **not recommended** in replication setups. * On primary: ```sql SELECT client_addr, state FROM pg_stat_replication; ``` * On standby: ```sql SELECT pg_is_in_recovery() AS in_recovery, pg_last_wal_receive_lsn() AS receive_lsn, pg_last_wal_replay_lsn() AS replay_lsn; ``` > [!TIP] > Want to verify that everything is working? After creating an encrypted table on the primary, run the following command on the standby to confirm that the encryption is active and the keys are resolved: > > ```sql > SELECT pg_tde_is_encrypted('your_encrypted_table'); > ``` [PG.CENTER edition](https://github.com/pgsty/doc.pg.center/blob/4410c32dc9186a22859008303f474b72a779f583/content/percona/replication.md) · [Upstream source](https://github.com/percona/pg_tde/blob/5dd7a9e4e3599d88546f5de67ff0f4ef3fe51a9a/documentation/docs/replication.md) --- Backlinks: - [Reference overview](/docs/tde/upstream/advanced-topics/tech-reference/) - [Documentation errata](/docs/tde/upstream/site/errata/) ================ Source: https://mimus.pgsty.com/docs/tde/upstream/advanced-topics/index.md ================ # Technical reference > Architecture, usage reference, GUC variables, functions, and replication details. --- LLMS index: [llms.txt](/llms.txt) --- > This is the Percona pg_tde 2.3.0 manual. For the paired build, backup tools and major upgrades, see [PG TDE on Mimus](/docs/tde/). [PG.CENTER edition](https://github.com/pgsty/doc.pg.center/blob/4410c32dc9186a22859008303f474b72a779f583/content/percona/advanced-topics/_index.md) · [Upstream source](https://github.com/percona/pg_tde/tree/5dd7a9e4e3599d88546f5de67ff0f4ef3fe51a9a) --- Section pages: - [Technical reference overview](/docs/tde/upstream/advanced-topics/tech-reference/): Find the architecture, configuration, SQL, and replication reference pages. - [Usage reference](/docs/tde/upstream/advanced-topics/usage-guide/): Understand provider namespaces, key scopes, permissions, and operational changes. --- Backlinks: - [Percona pg_tde 2.3.0](/docs/tde/upstream/) ================ Source: https://mimus.pgsty.com/docs/tde/upstream/advanced-topics/tech-reference/index.md ================ # Technical reference overview > Find the architecture, configuration, SQL, and replication reference pages. --- LLMS index: [llms.txt](/llms.txt) --- > This is the Percona pg_tde 2.3.0 manual. For the paired build, backup tools and major upgrades, see [PG TDE on Mimus](/docs/tde/). This section covers the internal components and tools that power `pg_tde`. Use it to understand how encryption is implemented, fine-tune a configuration, leverage advanced CLI tools and functions for diagnostics and customization. ### Usage reference {#usage-reference} A description of the main `pg_tde` operations available, including configuring key providers, managing principal keys, setting permissions, and encrypting tables. [Follow the usage guide ](/docs/tde/upstream/advanced-topics/usage-guide/) ### Functions {#functions} Use built-in functions to manage key providers, create and rotate principal keys, and verify encryption status. Includes commands for Vault, KMIP, and local providers, plus utilities to inspect or validate keys. [Browse available functions →](/docs/tde/upstream/functions/) ### GUC Variables {#guc-variables} Configure how `pg_tde` behaves with PostgreSQL. Control WAL encryption, enforce encryption for new tables, and manage global provider inheritance. Includes scope levels, defaults, and permission requirements. [Configure GUC variables ](/docs/tde/upstream/variables/) ### Streaming replication {#streaming-replication} Learn how to configure PostgreSQL streaming replication with `pg_tde` using the `tde_heap` access method. Covers primary and standby setup, key management requirements, and validation steps. [Set up replication with `tde_heap` ](/docs/tde/upstream/replication/) [PG.CENTER edition](https://github.com/pgsty/doc.pg.center/blob/4410c32dc9186a22859008303f474b72a779f583/content/percona/advanced-topics/tech-reference.md) · [Upstream source](https://github.com/percona/pg_tde/blob/5dd7a9e4e3599d88546f5de67ff0f4ef3fe51a9a/documentation/docs/advanced-topics/tech-reference.md) --- Backlinks: - [2.1.2](/docs/tde/upstream/release-notes/release-notes-v2.1.2/) - [WAL encryption](/docs/tde/upstream/wal-encryption/) ================ Source: https://mimus.pgsty.com/docs/tde/upstream/advanced-topics/usage-guide/index.md ================ # Usage reference > Understand provider namespaces, key scopes, permissions, and operational changes. --- LLMS index: [llms.txt](/llms.txt) --- > This is the Percona pg_tde 2.3.0 manual. For the paired build, backup tools and major upgrades, see [PG TDE on Mimus](/docs/tde/). > [!NOTE] Editorial correction > Obsolete GUC names and invalid server/default function variants are corrected against the pinned source code. See [site errata](/docs/tde/upstream/site/errata/). This chapter describes the main `pg_tde` operations available, including configuring key providers, managing principal keys, setting permissions, and encrypting tables. Use this chapter as a reference when performing specific `pg_tde` tasks. ## Prerequisites {#prerequisites} Before using `pg_tde`, complete the setup steps as described in [Install pg_tde](/docs/tde/upstream/install/). ## Add providers {#add-providers} You can add key providers to either the global or database specific scope. If `pg_tde.inherit_global_providers` is `on`, global providers are visible for all databases, and can be used. If `pg_tde.inherit_global_providers` is `off`, global providers are only used for WAL encryption. To add a global provider: ```sql pg_tde_add_global_key_provider_('provider_name', ... details ...) ``` To add a database specific provider: ```sql pg_tde_add_database_key_provider_('provider_name', ... details ...) ``` ## Change providers {#change-providers} To change a value of a global provider: ```sql pg_tde_change_global_key_provider_('provider_name', ... details ...) ``` To change a value of a database specific provider: ```sql pg_tde_change_database_key_provider_('provider_name', ... details ...) ``` These functions also allow changing the type of a provider but **do not** migrate any data. They are expected to be used during infrastructure migration, for example when the address of a server changes. ## Change providers from the command line {#change-providers-from-the-command-line} To change a provider from a command line, `pg_tde` provides the `pg_tde_change_key_provider` command line tool. This tool works similarly to the above functions, with the following syntax: ```sh pg_tde_change_key_provider ... details ... ``` > [!NOTE] > Since this tool is intended to be run while the PostgreSQL server is stopped, it bypasses all permission checks. For this reason, it requires a database OID (`dbOid`) instead of a database name, as it cannot access the system catalogs. > > This tool does not validate any parameters. ## Delete providers {#delete-providers} Providers can be deleted by using the following functions: ```sql pg_tde_delete_database_key_provider(provider_name) pg_tde_delete_global_key_provider(provider_name) ``` For database specific providers, the function first checks if the provider is used or not, and the provider is only deleted if it's not used. For global providers, the function checks if the provider is used anywhere, WAL or any specific database, and returns an error if it is. ## List/query providers {#list-query-providers} `pg_tde` provides 2 functions to show providers: * `pg_tde_list_all_database_key_providers()` * `pg_tde_list_all_global_key_providers()` These functions return a list of provider names, type and configuration. ## Provider permissions {#provider-permissions} `pg_tde` implements access control based on execution rights on the administration functions. For keys and providers administration, it provides two functions: ```sql pg_tde_GRANT_database_key_management_TO_role(role_name) pg_tde_REVOKE_database_key_management_FROM_role(role_name) ``` These functions take a role name as a string argument, for example `'user1'`. ## Create and rotate keys {#create-and-rotate-keys} Principal keys can be created using the following functions: ```sql pg_tde_create_key_using_(global/database)_key_provider('key-name', 'provider-name') ``` Principal keys can be used or rotated using the following functions: ```sql pg_tde_set_key_using_(global/database)_key_provider('key-name', 'provider-name') pg_tde_set_server_key_using_global_key_provider('key-name', 'provider-name') pg_tde_set_default_key_using_global_key_provider('key-name', 'provider-name') ``` ## Default principal key {#default-principal-key} With `pg_tde.inherit_global_providers`, it is also possible to set up a default global principal key, which will be used by any database which has the `pg_tde` extension enabled, but doesn't have a database specific principal key configured using `pg_tde_set_key_using_(global/database)_key_provider`. With this feature, it is possible for the entire database server to easily use the same principal key for all databases, completely disabling multi-tenancy. ### Manage a default key {#manage-a-default-key} You can manage a default key with the following functions: * `pg_tde_create_key_using_global_key_provider('key-name','provider-name')` * `pg_tde_set_default_key_using_global_key_provider('key-name','provider-name')` * `pg_tde_delete_default_key()` > [!NOTE] > `pg_tde_delete_default_key()` is only possible if there's no database currently using the default principal key. > Changing the default principal key will rotate the encryption of internal keys for all databases using the current default principal key. ### Delete a key {#delete-a-key} The `pg_tde_delete_key()` function unsets the principal key for the current database. If the current database has any encrypted tables, and there isn’t a default principal key configured, it reports an error instead. If there are encrypted tables, but there’s also a default principal key, internal keys will be encrypted with the default key. > [!NOTE] > WAL keys **cannot** be unset, as server keys are managed separately. ## Current key details {#current-key-details} `pg_tde_key_info()` returns the name of the current principal key, and the provider it uses. `pg_tde_server_key_info()` does the same for the server key. `pg_tde_default_key_info()` does the same for the default key. `pg_tde_verify_key()` checks that the key provider is accessible, that the current principal key can be downloaded from it, and that it is the same as the current key stored in memory - if any of these fail, it reports an appropriate error. ## Key permissions {#key-permissions} Users with management permissions to a specific database `(pg_tde_(grant/revoke)_(global/database)_key_management_(to/from)_role)` can change the keys for the database, and use the current key functions. This includes creating keys using global providers, if `pg_tde.inherit_global_providers` is enabled. Also the `pg_tde_(grant/revoke)_database_key_management_to_role` function deals with only the specific permission for the above function: it allows a user to change the key for the database, but not to modify the provider configuration. ## Create an encrypted table {#create-an-encrypted-table} To create an encrypted table, use the following command: ```sql CREATE TABLE t1(a INT) USING tde_heap; ``` ## Alter an encrypted table {#alter-an-encrypted-table} To alter or modify an encrypted table, use the following command: ```sql ALTER TABLE t1; ``` ## Change the pg_tde.inherit_global_providers setting {#change-the-pgtde-inheritglobalkeys-setting} It is possible to use `pg_tde` with `pg_tde.inherit_global_providers = on`, refer to the global keys or keyrings in databases, and then change this setting to `off`. In this case, existing references to global providers or the global default principal key keep working as before, but new references to the global scope cannot be made. [PG.CENTER edition](https://github.com/pgsty/doc.pg.center/blob/4410c32dc9186a22859008303f474b72a779f583/content/percona/advanced-topics/usage-guide.md) · [Upstream source](https://github.com/percona/pg_tde/blob/5dd7a9e4e3599d88546f5de67ff0f4ef3fe51a9a/documentation/docs/advanced-topics/usage-guide.md) --- Backlinks: - [Reference overview](/docs/tde/upstream/advanced-topics/tech-reference/) - [Default principal key](/docs/tde/upstream/global-key-provider-configuration/set-principal-key/) - [2.1.2](/docs/tde/upstream/release-notes/release-notes-v2.1.2/) - [Documentation errata](/docs/tde/upstream/site/errata/) ================ Source: https://mimus.pgsty.com/docs/tde/upstream/variables/index.md ================ # GUC Variables > Reference for WAL encryption, enforcement, global providers, and cipher selection. --- LLMS index: [llms.txt](/llms.txt) --- > This is the Percona pg_tde 2.3.0 manual. For the paired build, backup tools and major upgrades, see [PG TDE on Mimus](/docs/tde/). The `pg_tde` extension provides GUC variables to configure the behaviour of the extension: ## pg_tde.wal_encrypt {#pgtde-walencrypt} **Type** - boolean
**Default** - off A `boolean` variable that controls if WAL writes are encrypted or not. Changing this variable requires a server restart, and can only be set at the server level. WAL encryption is controlled globally. If enabled, all WAL writes are encrypted in the entire PostgreSQL cluster. This variable only controls new writes to the WAL, it doesn't affect existing WAL records. `pg_tde` is always capable of reading existing encrypted WAL records, as long as the keys used for the encryption are still available. Enabling WAL encryption requires a configured global principal key. Refer to the [WAL encryption configuration](/docs/tde/upstream/wal-encryption/) topic for more information. ## pg_tde.enforce_encryption {#pgtde-enforceencryption} **Type** - boolean
**Default** - off A `boolean` variable that controls if the creation of new, not encrypted tables is allowed. If enabled, `CREATE TABLE` statements will fail unless they use the `tde_heap` access method. Similarly, `ALTER TABLE SET ACCESS METHOD` is only allowed, if the access method is `tde_heap`. Other DDL operations are still allowed. For example other `ALTER` commands are allowed on unencrypted tables, as long as the access method isn't changed. You can set this variable at the following levels: * global - for the entire PostgreSQL cluster * database - for specific databases * user - for specific users * session - for the current session Setting or changing the value requires superuser permissions. For examples, see the [Encryption Enforcement](/docs/tde/upstream/how-to/enforcement/) topic. ## pg_tde.inherit_global_providers {#pgtde-inheritglobalproviders} **Type** - boolean
**Default** - on A `boolean` variable that controls if databases can use global key providers for storing principal keys. If disabled, functions that change the key providers can only work with database local key providers. In this case, the default principal key, if set, is also disabled. You can set this variable at the following levels: * global - for the entire PostgreSQL cluster * database - for specific databases * user - for specific users * session - for the current session > [!NOTE] > Setting this variable doesn't affect existing uses of global keys. It only prevents the creation of new principal keys using global providers. ## pg_tde.cipher {#pgtde-cipher} **Type** - string
**Default** - aes_128 A `string` variable that selects the cipher (encryption algorithm). Currently, the supported values are `aes_128` and `aes_256`, corresponding to AES 128-bit and 256-bit key lengths, respectively. The setting applies only to objects created after the value is set, including principal keys, internal keys, and data encrypted by those keys. Existing objects are not re-encrypted. [PG.CENTER edition](https://github.com/pgsty/doc.pg.center/blob/4410c32dc9186a22859008303f474b72a779f583/content/percona/variables.md) · [Upstream source](https://github.com/percona/pg_tde/blob/5dd7a9e4e3599d88546f5de67ff0f4ef3fe51a9a/documentation/docs/variables.md) --- Backlinks: - [PG TDE](/docs/tde/) - [Reference overview](/docs/tde/upstream/advanced-topics/tech-reference/) - [Encryption architecture](/docs/tde/upstream/architecture/encryption-architecture/) - [Major upgrade](/docs/tde/upstream/command-line-tools/pg-tde-upgrade/) - [Encryption enforcement](/docs/tde/upstream/how-to/enforcement/) ================ Source: https://mimus.pgsty.com/docs/tde/upstream/functions/index.md ================ # Functions > SQL reference for providers, principal keys, privileges, and encryption status. --- LLMS index: [llms.txt](/llms.txt) --- > This is the Percona pg_tde 2.3.0 manual. For the paired build, backup tools and major upgrades, see [PG TDE on Mimus](/docs/tde/). > [!NOTE] Editorial correction > Parameter names and key scopes are corrected against the pinned source code. See [site errata](/docs/tde/upstream/site/errata/). The `pg_tde` extension provides functions for managing different aspects of its operation: > [!NOTE] > If no error is reported when running the commands below, the operation completed successfully. ## Key provider management {#key-provider-management} A key provider is a system or service responsible for managing encryption keys. For more information on the key providers `pg_tde` supports see the [Key management overview](/docs/tde/upstream/global-key-provider-configuration/overview/). Key provider management includes the following operations: * [add a new key provider](#add-a-key-provider) * [change an existing key provider](#change-an-existing-provider) * [delete a key provider](#delete-a-provider) * [list key providers](#list-key-providers) ### Add a key provider {#add-a-key-provider} You can add a new key provider using the provided functions, which are implemented for each provider type. There are two functions to add a key provider: one function adds it for the current database and another one - for the global scope. * `pg_tde_add_database_key_provider_('provider-name', )` * `pg_tde_add_global_key_provider_('provider-name', )` When you add a new provider, the provider name must be unique in the scope. But a local database provider and a global provider can have the same name. ### Change an existing provider {#change-an-existing-provider} You can change an existing key provider using the provided functions, which are implemented for each provider type. There are two functions to change existing providers: one to change a provider in the current database, and another one to change a provider in the global scope. * `pg_tde_change_database_key_provider_('provider-name', )` * `pg_tde_change_global_key_provider_('provider-name', )` When you change a provider, the referred name must exist in the database local or a global scope. The `change` functions require the same parameters as the `add` functions. They overwrite the setting for every parameter except for the name, which can't be changed. Provider specific parameters differ for each implementation. Refer to the respective subsection for details. > [!NOTE] > The updated provider must be able to retrieve the same principal keys as the original configuration. > If the new configuration cannot access existing keys, encrypted data and backups will become unreadable. #### Add or modify Vault providers {#add-or-modify-vault-providers} The Vault provider connects to a HashiCorp Vault or an OpenBao server, and stores the keys on a key-value store version 2. Use the following functions to add the Vault provider: ```sql SELECT pg_tde_add_database_key_provider_vault_v2( 'provider-name', 'url', 'mount', 'secret_token_path', 'ca_path' ); SELECT pg_tde_add_global_key_provider_vault_v2( 'provider-name', 'url', 'mount', 'secret_token_path', 'ca_path' ); SELECT pg_tde_add_database_key_provider_vault_v2( 'provider-name', 'url', 'mount', 'secret_token_path', 'ca_path', 'namespace' ); SELECT pg_tde_add_global_key_provider_vault_v2( 'provider-name', 'url', 'mount', 'secret_token_path', 'ca_path', 'namespace' ); ``` These functions change the Vault provider: ```sql SELECT pg_tde_change_database_key_provider_vault_v2( 'provider-name', 'url', 'mount', 'secret_token_path', 'ca_path' ); SELECT pg_tde_change_global_key_provider_vault_v2( 'provider-name', 'url', 'mount', 'secret_token_path', 'ca_path' ); SELECT pg_tde_change_database_key_provider_vault_v2( 'provider-name', 'url', 'mount', 'secret_token_path', 'ca_path', 'namespace' ); SELECT pg_tde_change_global_key_provider_vault_v2( 'provider-name', 'url', 'mount', 'secret_token_path', 'ca_path', 'namespace' ); ``` where: * `provider-name` is the name of the key provider * `url` is the URL of the Vault server * `mount` is the mount point on the Vault server where the key provider should store the keys * `secret_token_path` is a path to the file that contains an access token with read and write access to the above mount point * **[optional]** `ca_path` is the path of the CA file used for SSL verification * **[namespace]** `namespace` is the path of the namespace when using [Vault with namespaes](https://developer.hashicorp.com/vault/docs/enterprise/namespaces) #### Add or modify KMIP providers {#add-or-modify-kmip-providers} The KMIP provider uses a remote KMIP server. Use these functions to add a KMIP provider: ```sql SELECT pg_tde_add_database_key_provider_kmip( 'provider-name', 'kmip-addr', port, '/path_to/client_cert.pem', '/path_to/client_key.pem', '/path_to/server_certificate.pem' ); SELECT pg_tde_add_global_key_provider_kmip( 'provider-name', 'kmip-addr', port, '/path_to/client_certificate.pem', '/path_to/client_key.pem', '/path_to/server_certificate.pem' ); ``` These functions change the KMIP provider: ```sql SELECT pg_tde_change_database_key_provider_kmip( 'provider-name', 'kmip-addr', port, '/path_to/client_cert.pem', '/path_to/client_key.pem', '/path_to/server_certificate.pem' ); SELECT pg_tde_change_global_key_provider_kmip( 'provider-name', 'kmip-addr', port, '/path_to/client_certificate.pem', '/path_to/client_key.pem', '/path_to/server_certificate.pem' ); ``` where: * `provider-name` is the name of the provider * `kmip-addr` is the IP address or domain name of the KMIP server * `port` is the port to communicate with the KMIP server. Most KMIP servers use port 5696. * `server-certificate` is the path to the certificate file for the KMIP server. * `client-certificate` is the path to the client certificate. * `client-key` is the path to the client key. > [!NOTE] > The specified access parameters require permission to read and write keys at the server. ### Add or modify local key file providers {#add-or-modify-local-key-file-providers} This provider manages database keys using a local key file. This function is intended for development or quick testing, and stores the keys unencrypted in the specified data file. > [!IMPORTANT] > Local key file providers are **not recommended** for production environments, they lack the security and manageability of external key management systems. Add a local key file provider: ```sql SELECT pg_tde_add_database_key_provider_file( 'provider-name', '/path/to/the/key/provider/data.file' ); SELECT pg_tde_add_global_key_provider_file( 'provider-name', '/path/to/the/key/provider/data.file' ); ``` Change a local key file provider: ```sql SELECT pg_tde_change_database_key_provider_file( 'provider-name', '/path/to/the/key/provider/data.file' ); SELECT pg_tde_change_global_key_provider_file( 'provider-name', '/path/to/the/key/provider/data.file' ); ``` where: * `provider-name` is the name of the provider. You can specify any name, it's for you to identify the provider. * `/path/to/the/key/provider/data.file` is the path to the key provider file. ### Delete a provider {#delete-a-provider} These functions delete an existing provider in the current database or in the global scope: * `pg_tde_delete_database_key_provider('provider-name')` * `pg_tde_delete_global_key_provider('provider-name')` You can only delete key providers that are not currently in use. An error is returned if the current principal key is using the provider you are trying to delete. If the use of global key providers is enabled via the `pg_tde.inherit_global_providers` GUC, you can delete a global key provider only if it isn't used anywhere, including any databases. If it is used in any database, an error is returned instead. ### List key providers {#list-key-providers} These functions list the details of all key providers for the current database or for the global scope, including all configuration values: * `pg_tde_list_all_database_key_providers()` * `pg_tde_list_all_global_key_providers()` ## Principal key management {#principal-key-management} Use these functions to create a new principal key at a given keyprover, and to use those keys for a specific scope such as a current database, a global or default scope. You can also use them to start using a different existing key for a specific scope. Principal keys are stored on key providers by the name specified in this function - for example, when using the Vault provider, after creating a key named "foo", a key named "foo" will be visible on the Vault server at the specified mount point. ### pg_tde_create_key_using_database_key_provider {#pgtdecreatekeyusingdatabasekeyprovider} Creates a principal key using the database-local key provider with the specified name. Use this key later with [`pg_tde_set_key_using_database_key_provider()`](#pgtdesetkeyusingdatabasekeyprovider). ```sql SELECT pg_tde_create_key_using_database_key_provider( 'key-name', 'provider-name' ); ``` ### pg_tde_create_key_using_global_key_provider {#pgtdecreatekeyusingglobalkeyprovider} Creates a principal key at a global key provider with the given name. Use this key later with the `pg_tde_set_*` series of functions. ```sql SELECT pg_tde_create_key_using_global_key_provider( 'key-name', 'provider-name' ); ``` ### pg_tde_set_key_using_database_key_provider {#pgtdesetkeyusingdatabasekeyprovider} Sets the principal key for the **current** database, using the specified local key provider. It also rotates internal encryption keys to use the specified principal key. This function is typically used when working with per-database encryption through a local key provider. ```sql SELECT pg_tde_set_key_using_database_key_provider( 'key-name', 'provider-name' ); ``` ### pg_tde_set_key_using_global_key_provider {#pgtdesetkeyusingglobalkeyprovider} Sets or rotates the principal key for the **current database**, using the specified global key provider. For WAL encryption, use `pg_tde_set_server_key_using_global_key_provider`. ```sql SELECT pg_tde_set_key_using_global_key_provider( 'key-name', 'provider-name' ); ``` ### pg_tde_set_server_key_using_global_key_provider {#pgtdesetserverkeyusingglobalkeyprovider} Sets or rotates the server principal key using the specified global key provider. Use this function to set a principal key for WAL encryption. ```sql SELECT pg_tde_set_server_key_using_global_key_provider( 'key-name', 'provider-name' ); ``` ### pg_tde_set_default_key_using_global_key_provider {#pgtdesetdefaultkeyusingglobalkeyprovider} Sets or rotates the default principal key for the server using the specified global key provider. The default key is automatically used as a principal key by any database that doesn't have an individual key provider and key configuration. ```sql SELECT pg_tde_set_default_key_using_global_key_provider( 'key-name', 'provider-name' ); ``` ### pg_tde_delete_key {#pgtdedeletekey} Unsets the principal key for the current database. If the current database has any encrypted tables, and there isn’t a default principal key configured, it reports an error instead. If there are encrypted tables, but there’s also a default principal key, internal keys will be encrypted with the default key. ```sql SELECT pg_tde_delete_key(); ``` ### pg_tde_delete_default_key {#pgtdedeletedefaultkey} Unsets default principal key. It's possible only if no database uses default principal key. ```sql SELECT pg_tde_delete_default_key(); ``` ## Encryption status check {#encryption-status-check} ### pg_tde_is_encrypted {#pgtdeisencrypted} Tells if a relation is encrypted using the `pg_tde` extension or not. Returns `NULL` if a relation lacks storage like views, foreign tables, and partitioned tables and indexes. To verify that a table is encrypted, run the following statement: ```sql SELECT pg_tde_is_encrypted( 'table_name' ); ``` You can also verify if the table in a custom schema is encrypted. Pass the schema name for the function as follows: ```sql SELECT pg_tde_is_encrypted( 'schema.table_name' ); ``` This can additionally be used to verify that indexes and sequences are encrypted. ### pg_tde_key_info {#pgtdekeyinfo} Displays information about the principal key for the current database, if it exists. ```sql SELECT pg_tde_key_info(); ``` ### pg_tde_server_key_info {#pgtdeserverkeyinfo} Displays information about the principal key for the server scope, if exists. ```sql SELECT pg_tde_server_key_info(); ``` ### pg_tde_default_key_info {#pgtdedefaultkeyinfo} Displays the information about the default principal key, if it exists. ```sql SELECT pg_tde_default_key_info(); ``` ### pg_tde_verify_key {#pgtdeverifykey} This function checks that the current database has a properly functional encryption setup, which means: * A key provider is configured * The key provider is accessible using the specified configuration * There is a principal key for the database * The principal key can be retrieved from the remote key provider * The principal key returned from the key provider is the same as cached in the server memory If any of the above checks fail, the function reports an error. ```sql SELECT pg_tde_verify_key(); ``` ### pg_tde_verify_server_key {#pgtdeverifyserverkey} This function checks that the server scope has a properly functional encryption setup, which means: * A key provider is configured * The key provider is accessible using the specified configuration * There is a principal key for the global scope * The principal key can be retrieved from the remote key provider * The principal key returned from the key provider is the same as cached in the server memory If any of the above checks fail, the function reports an error. ```sql SELECT pg_tde_verify_server_key(); ``` ### pg_tde_verify_default_key {#pgtdeverifydefaultkey} This function checks that the default key is properly configured, which means: * A key provider is configured * The key provider is accessible using the specified configuration * There is a principal key that can be used for any scope * The principal key can be retrieved from the remote key provider * The principal key returned from the key provider is the same as cached in the server memory If any of the above checks fail, the function reports an error. ```sql SELECT pg_tde_verify_default_key(); ``` [PG.CENTER edition](https://github.com/pgsty/doc.pg.center/blob/4410c32dc9186a22859008303f474b72a779f583/content/percona/functions.md) · [Upstream source](https://github.com/percona/pg_tde/blob/5dd7a9e4e3599d88546f5de67ff0f4ef3fe51a9a/documentation/docs/functions.md) --- Backlinks: - [PG TDE](/docs/tde/) - [Reference overview](/docs/tde/upstream/advanced-topics/tech-reference/) - [Keys and providers](/docs/tde/upstream/architecture/key-provider-management/) - [Change key provider](/docs/tde/upstream/command-line-tools/pg-tde-change-key-provider/) - [Local keyring](/docs/tde/upstream/global-key-provider-configuration/keyring/) - [Akeyless](/docs/tde/upstream/global-key-provider-configuration/kmip-akeyless/) - [Fortanix DSM](/docs/tde/upstream/global-key-provider-configuration/kmip-fortanix/) - [KMIP setup](/docs/tde/upstream/global-key-provider-configuration/kmip-server/) - [Thales CipherTrust](/docs/tde/upstream/global-key-provider-configuration/kmip-thales/) - [OpenBao](/docs/tde/upstream/global-key-provider-configuration/openbao/) - [Default principal key](/docs/tde/upstream/global-key-provider-configuration/set-principal-key/) - [HashiCorp Vault](/docs/tde/upstream/global-key-provider-configuration/vault/) - [RC 1](/docs/tde/upstream/release-notes/rc/) - [2.1.0](/docs/tde/upstream/release-notes/release-notes-v2.1/) - [Streaming replication](/docs/tde/upstream/replication/) - [Documentation errata](/docs/tde/upstream/site/errata/) - [Verify encryption](/docs/tde/upstream/test/) - [WAL encryption](/docs/tde/upstream/wal-encryption/) ================ Source: https://mimus.pgsty.com/docs/tde/upstream/command-line-tools/index.md ================ # Command-line tools > Reference pages for the pg_tde utilities used with encrypted data and WAL. --- LLMS index: [llms.txt](/llms.txt) --- > This is the Percona pg_tde 2.3.0 manual. For the paired build, backup tools and major upgrades, see [PG TDE on Mimus](/docs/tde/). [PG.CENTER edition](https://github.com/pgsty/doc.pg.center/blob/4410c32dc9186a22859008303f474b72a779f583/content/percona/command-line-tools/_index.md) · [Upstream source](https://github.com/percona/pg_tde/tree/5dd7a9e4e3599d88546f5de67ff0f4ef3fe51a9a) --- Section pages: - [Overview of pg_tde CLI tools](/docs/tde/upstream/command-line-tools/cli-tools/): Choose the pg_tde-aware utilities required for encrypted data and WAL. - [pg_tde_archive_decrypt](/docs/tde/upstream/command-line-tools/pg-tde-archive-decrypt/): Decrypt WAL while wrapping an archive command for tools that require plaintext WAL. - [pg_tde_restore_encrypt](/docs/tde/upstream/command-line-tools/pg-tde-restore-encrypt/): Wrap a restore command and encrypt the retrieved WAL before PostgreSQL reads it. - [pg_tde_change_key_provider](/docs/tde/upstream/command-line-tools/pg-tde-change-key-provider/): Change provider configuration in an offline data directory. - [pg_tde_checksums](/docs/tde/upstream/command-line-tools/pg-tde-checksums/): Check or change checksums with pg_tde support on PostgreSQL 17 and later. - [pg_tde_waldump](/docs/tde/upstream/command-line-tools/pg-tde-waldump/): Inspect encrypted WAL with a pg_tde-aware version of pg_waldump. - [pg_tde_upgrade](/docs/tde/upstream/command-line-tools/pg-tde-upgrade/): Upgrade PostgreSQL data directories that contain pg_tde-encrypted relations. --- Backlinks: - [PG TDE](/docs/tde/) ================ Source: https://mimus.pgsty.com/docs/tde/upstream/command-line-tools/cli-tools/index.md ================ # Overview of pg_tde CLI tools > Choose the pg_tde-aware utilities required for encrypted data and WAL. --- LLMS index: [llms.txt](/llms.txt) --- > This is the Percona pg_tde 2.3.0 manual. For the paired build, backup tools and major upgrades, see [PG TDE on Mimus](/docs/tde/). The `pg_tde` extension provides a set of command-line utilities designed specifically for operating on encrypted data and clusters. These utilities exist in parallel with the standard PostgreSQL utilities but you **must** use them when working with data encrypted by `pg_tde`. > [!NOTE] > The standard PostgreSQL tools cannot operate on `pg_tde`-encrypted WAL or tables. ## New `pg_tde` specific tools {#new-pgtde-specific-tools} These tools are introduced exclusively by `pg_tde` to support key rotation and WAL encryption workflows: * [pg_tde_change_key_provider](/docs/tde/upstream/command-line-tools/pg-tde-change-key-provider/): change the encryption key provider for a database * [pg_tde_archive_decrypt](/docs/tde/upstream/command-line-tools/pg-tde-archive-decrypt/): decrypts WAL before archiving * [pg_tde_restore_encrypt](/docs/tde/upstream/command-line-tools/pg-tde-restore-encrypt/): a custom restore command for making sure the restored WAL is encrypted ## Tools for working with `pg_tde`-encrypted data {#tools-for-working-with-pgtde-encrypted-data} These tools are modified versions of standard PostgreSQL utilities that include `pg_tde` support. You must use the `pg_tde_*` variants when working with encrypted WAL or tables: * [pg_tde_checksums](/docs/tde/upstream/command-line-tools/pg-tde-checksums/): verify data checksums * [pg_tde_waldump](/docs/tde/upstream/command-line-tools/pg-tde-waldump/): inspect and decrypt WAL files * [pg_tde_basebackup](/docs/tde/upstream/how-to/backup-wal-enabled/): create base backups that include encrypted data * pg_tde_resetwal: reset the WAL for clusters using `pg_tde` * pg_tde_rewind: rewind clusters that use encrypted WAL * [pg_tde_upgrade](/docs/tde/upstream/command-line-tools/pg-tde-upgrade/): perform major version upgrades of clusters with `pg_tde` [PG.CENTER edition](https://github.com/pgsty/doc.pg.center/blob/4410c32dc9186a22859008303f474b72a779f583/content/percona/command-line-tools/cli-tools.md) · [Upstream source](https://github.com/percona/pg_tde/blob/5dd7a9e4e3599d88546f5de67ff0f4ef3fe51a9a/documentation/docs/command-line-tools/cli-tools.md) --- Backlinks: - [Keys and providers](/docs/tde/upstream/architecture/key-provider-management/) - [2.0.0](/docs/tde/upstream/release-notes/release-notes-v2.0/) ================ Source: https://mimus.pgsty.com/docs/tde/upstream/command-line-tools/pg-tde-archive-decrypt/index.md ================ # pg_tde_archive_decrypt > Decrypt WAL while wrapping an archive command for tools that require plaintext WAL. --- LLMS index: [llms.txt](/llms.txt) --- > This is the Percona pg_tde 2.3.0 manual. For the paired build, backup tools and major upgrades, see [PG TDE on Mimus](/docs/tde/). The `pg_tde_archive_decrypt` tool wraps an archive command and decrypts WAL files before archiving. It allows external tools to access unencrypted WAL data, which is required because WAL encryption keys in the two-key hierarchy are host-specific and may not be available on the replay host. > [!TIP] > For more information on the encryption architecture and key hierarchy, see [Architecture](/docs/tde/upstream/architecture/overview/). This tool is often used in conjunction with [pg_tde_restore_encrypt](/docs/tde/upstream/command-line-tools/pg-tde-restore-encrypt/) to support WAL archive. ## How it works {#how-it-works} 1. Decrypts the WAL segment to a temporary file on a RAM disk (`/dev/shm`) 2. Replaces `%p` and `%f` in the archive command with the path and name of the decrypted file 3. Executes the archive command > [!NOTE] > > To ensure security, encrypt the files stored in your WAL archive using tools like `PgBackRest`. ## Usage {#usage} ```bash pg_tde_archive_decrypt [OPTION] pg_tde_archive_decrypt DEST-NAME SOURCE-PATH ARCHIVE-COMMAND ``` ## Parameter descriptions {#parameter-descriptions} * `DEST-NAME`: name of the WAL file to send to the archive * `SOURCE-PATH`: path to the original encrypted WAL file * `ARCHIVE-COMMAND`: archive command to wrap. `%p` and `%f` are replaced with the decrypted WAL file path and WAL file name, respectively. ## Options {#options} * `-V, --version`: show version information, then exit * `-?, --help`: show help information, then exit > [!NOTE] > > Any `%f` or `%p` parameter in `ARCHIVE-COMMAND` has to be escaped as `%%f` or `%%p` respectively if used as `archive_command` in `postgresql.conf`. ## Examples {#examples} ### Using `cp` {#using-cp} ```ini archive_command='pg_tde_archive_decrypt %f %p "cp %%p /mnt/server/archivedir/%%f"' ``` ### Using `PgBackRest` {#using-pgbackrest} ```ini archive_command='pg_tde_archive_decrypt %f %p "pgbackrest --stanza=your_stanza archive-push %%p"' ``` > [!WARNING] Required configuration > > A deployment with WAL encryption is not supported unless `archive_command` uses `pg_tde_archive_decrypt` and `restore_command` uses [`pg_tde_restore_encrypt`](/docs/tde/upstream/command-line-tools/pg-tde-restore-encrypt/). > > Disable the following pgBackRest features in the applicable pgBackRest configuration section: > > ```ini > archive-async=n > archive-header-check=n > checksum-page=n > ``` [PG.CENTER edition](https://github.com/pgsty/doc.pg.center/blob/4410c32dc9186a22859008303f474b72a779f583/content/percona/command-line-tools/pg-tde-archive-decrypt.md) · [Upstream source](https://github.com/percona/pg_tde/blob/5dd7a9e4e3599d88546f5de67ff0f4ef3fe51a9a/documentation/docs/command-line-tools/pg-tde-archive-decrypt.md) --- Backlinks: - [Tool overview](/docs/tde/upstream/command-line-tools/cli-tools/) - [Restore WAL](/docs/tde/upstream/command-line-tools/pg-tde-restore-encrypt/) - [WAL encryption](/docs/tde/upstream/wal-encryption/) ================ Source: https://mimus.pgsty.com/docs/tde/upstream/command-line-tools/pg-tde-restore-encrypt/index.md ================ # pg_tde_restore_encrypt > Wrap a restore command and encrypt the retrieved WAL before PostgreSQL reads it. --- LLMS index: [llms.txt](/llms.txt) --- > This is the Percona pg_tde 2.3.0 manual. For the paired build, backup tools and major upgrades, see [PG TDE on Mimus](/docs/tde/). > [!NOTE] Editorial correction > The placeholder descriptions now match the tool’s built-in help. See [site errata](/docs/tde/upstream/site/errata/). The `pg_tde_restore_encrypt` tool wraps a normal restore command from the WAL archive and writes them to disk in a format compatible with `pg_tde`. > [!NOTE] > > This command is often use together with [pg_tde_archive_decrypt](/docs/tde/upstream/command-line-tools/pg-tde-archive-decrypt/). ## How it works {#how-it-works} 1. Replaces `%f` and `%p` in the restore command with the WAL file name and temporary file path (in `/dev/shm`) 2. Runs the restore command to fetch the unencrypted WAL from the archive and write it to the temp file 3. Encrypts the temp file and writes it to the destination path in PostgreSQL’s data directory ## Usage {#usage} ```bash pg_tde_restore_encrypt [OPTION] pg_tde_restore_encrypt SOURCE-NAME DEST-PATH RESTORE-COMMAND ``` ## Parameter descriptions {#parameter-descriptions} * `SOURCE-NAME`: name of the WAL file to retrieve from the archive * `DEST-PATH`: path where the encrypted WAL file should be written * `RESTORE-COMMAND`: restore command to wrap; `%f` and `%p` are replaced with the WAL file name and path to write the unencrypted WAL, respectively ## Options {#options} * `-V, --version`: show version information, then exit * `-?, --help`: show help information, then exit > [!NOTE] > > Any `%f` or `%p` parameter in `RESTORE-COMMAND` has to be escaped as `%%f` or `%%p` respectively if used as `restore_command` in `postgresql.conf`. ## Examples {#examples} ### Using `cp` {#using-cp} ```ini restore_command='pg_tde_restore_encrypt %f %p "cp /mnt/server/archivedir/%%f %%p"' ``` ### Using `PgBackRest` {#using-pgbackrest} ```ini restore_command='pg_tde_restore_encrypt %f %p "pgbackrest --stanza=your_stanza archive-get %%f \"%%p\""' ``` > [!WARNING] Required configuration > > A deployment with WAL encryption is not supported unless `archive_command` uses [`pg_tde_archive_decrypt`](/docs/tde/upstream/command-line-tools/pg-tde-archive-decrypt/) and `restore_command` uses `pg_tde_restore_encrypt`. > > Disable the following pgBackRest features in the applicable pgBackRest configuration section: > > ```ini > archive-async=n > archive-header-check=n > checksum-page=n > ``` [PG.CENTER edition](https://github.com/pgsty/doc.pg.center/blob/4410c32dc9186a22859008303f474b72a779f583/content/percona/command-line-tools/pg-tde-restore-encrypt.md) · [Upstream source](https://github.com/percona/pg_tde/blob/5dd7a9e4e3599d88546f5de67ff0f4ef3fe51a9a/documentation/docs/command-line-tools/pg-tde-restore-encrypt.md) --- Backlinks: - [Tool overview](/docs/tde/upstream/command-line-tools/cli-tools/) - [Archive WAL](/docs/tde/upstream/command-line-tools/pg-tde-archive-decrypt/) - [Documentation errata](/docs/tde/upstream/site/errata/) - [WAL encryption](/docs/tde/upstream/wal-encryption/) ================ Source: https://mimus.pgsty.com/docs/tde/upstream/command-line-tools/pg-tde-change-key-provider/index.md ================ # pg_tde_change_key_provider > Change provider configuration in an offline data directory. --- LLMS index: [llms.txt](/llms.txt) --- > This is the Percona pg_tde 2.3.0 manual. For the paired build, backup tools and major upgrades, see [PG TDE on Mimus](/docs/tde/). A tool for modifying the configuration of a key provider, possibly also changing its type. This tool edits the configuration files directly, ignoring permissions or running `postgres` processes. Its only intended use is to fix servers that can't start up because of inaccessible key providers. For example, you restore from an old backup and the address of the key provider changed in the meantime. You can use this tool to correct the configuration, allowing the server to start up. **Warning:** Use this tool **only when the server is offline.** To modify the key provider configuration when the server is up and running, use the [`pg_tde_change_(global/database)_key_provider_`](/docs/tde/upstream/functions/#change-an-existing-provider) SQL functions. ## Example usage {#example-usage} To modify the key provider configuration, specify all parameters depending on the provider type in the same way as you do when using the [`pg_tde_change_(global/database)_key_provider_`](/docs/tde/upstream/functions/#change-an-existing-provider) SQL functions. The general syntax is as follows: ```sh pg_tde_change_key_provider [-D ] ``` ## Parameter description {#parameter-description} * [optional] `` is the data directory.`pg_tde` uses the `$PGDATA` environment variable if this is not specified * `` is the name you assigned to the key provider * `` can be a `file`, `vault` or `kmip` * `` Depending on the provider type, the additional parameters are: ```sh pg_tde_change_key_provider [-D ] file pg_tde_change_key_provider [-D ] vault-v2 [] pg_tde_change_key_provider [-D ] kmip [] ``` [PG.CENTER edition](https://github.com/pgsty/doc.pg.center/blob/4410c32dc9186a22859008303f474b72a779f583/content/percona/command-line-tools/pg-tde-change-key-provider.md) · [Upstream source](https://github.com/percona/pg_tde/blob/5dd7a9e4e3599d88546f5de67ff0f4ef3fe51a9a/documentation/docs/command-line-tools/pg-tde-change-key-provider.md) --- Backlinks: - [Tool overview](/docs/tde/upstream/command-line-tools/cli-tools/) - [Restore encrypted backups](/docs/tde/upstream/how-to/restore-backups/) ================ Source: https://mimus.pgsty.com/docs/tde/upstream/command-line-tools/pg-tde-checksums/index.md ================ # pg_tde_checksums > Check or change checksums with pg_tde support on PostgreSQL 17 and later. --- LLMS index: [llms.txt](/llms.txt) --- > This is the Percona pg_tde 2.3.0 manual. For the paired build, backup tools and major upgrades, see [PG TDE on Mimus](/docs/tde/). [`pg_tde_checksums` ](https://www.postgresql.org/docs/current/app-pgchecksums.html) is a PostgreSQL command-line utility used to enable, disable, or verify data checksums on a PostgreSQL data directory. The tool is modified to add support for working with encrypted tables. [PG.CENTER edition](https://github.com/pgsty/doc.pg.center/blob/4410c32dc9186a22859008303f474b72a779f583/content/percona/command-line-tools/pg-tde-checksums.md) · [Upstream source](https://github.com/percona/pg_tde/blob/5dd7a9e4e3599d88546f5de67ff0f4ef3fe51a9a/documentation/docs/command-line-tools/pg-tde-checksums.md) --- Backlinks: - [Tool overview](/docs/tde/upstream/command-line-tools/cli-tools/) ================ Source: https://mimus.pgsty.com/docs/tde/upstream/command-line-tools/pg-tde-waldump/index.md ================ # pg_tde_waldump > Inspect encrypted WAL with a pg_tde-aware version of pg_waldump. --- LLMS index: [llms.txt](/llms.txt) --- > This is the Percona pg_tde 2.3.0 manual. For the paired build, backup tools and major upgrades, see [PG TDE on Mimus](/docs/tde/). [`pg_tde_waldump` ](https://www.postgresql.org/docs/current/pgwaldump.html) displays a human-readable rendering of the Write-Ahead Log (WAL) for a PostgreSQL database cluster. To read encrypted WAL records, `pg_tde_waldump` provides the following additional option: * `-k, --keyring-path=PATH` is the path to the directory containing the WAL keyring configuration files. This is typically the `pg_tde/` directory inside the PostgreSQL data directory. The following files are included: * `wal_keys` * `1664_providers` > [!NOTE] > `pg_tde_waldump` cannot read encrypted WAL unless `--keyring-path` is specified. Since [pg_tde 2.3.0](/docs/tde/upstream/release-notes/release-notes-v2.3.0/), `pg_tde_waldump` recognizes the `pg_tde` custom resource manager, prints its WAL records correctly, and accepts it in the `--rmgr` filter. [PG.CENTER edition](https://github.com/pgsty/doc.pg.center/blob/4410c32dc9186a22859008303f474b72a779f583/content/percona/command-line-tools/pg-tde-waldump.md) · [Upstream source](https://github.com/percona/pg_tde/blob/5dd7a9e4e3599d88546f5de67ff0f4ef3fe51a9a/documentation/docs/command-line-tools/pg-tde-waldump.md) --- Backlinks: - [Tool overview](/docs/tde/upstream/command-line-tools/cli-tools/) ================ Source: https://mimus.pgsty.com/docs/tde/upstream/command-line-tools/pg-tde-upgrade/index.md ================ # pg_tde_upgrade > Upgrade PostgreSQL data directories that contain pg_tde-encrypted relations. --- LLMS index: [llms.txt](/llms.txt) --- > This physical upgrade procedure applies to Percona PostgreSQL. For a major upgrade of a TDE-marked Mimus cluster, use logical dump and restore into a new cluster. [Mimus procedure](/docs/tde/recovery/#upgrade) `pg_tde_upgrade` is the supported method for performing PostgreSQL major version upgrades on clusters that use `pg_tde`. Use this tool instead of `pg_upgrade` whenever the cluster uses `pg_tde`, including clusters with encrypted tables or encrypted WAL. `pg_tde_upgrade` wraps [`pg_upgrade` ](https://www.postgresql.org/docs/current/pgupgrade.html) to simplify upgrading clusters with encrypted relations or WAL. It can also be run safely on clusters without `pg_tde` enabled. ## When to use which upgrade procedure {#when-to-use-which-upgrade-procedure} | Scenario | Procedure | |-----------|-----------| | Upgrade Percona PostgreSQL from one major version to another (for example from 17 to 18) on a cluster that uses `pg_tde` | Use this `pg_tde_upgrade` procedure | | Upgrade the `pg_tde` extension or package version within the same PostgreSQL major version | Follow the `pg_tde` [upgrade procedure](/docs/tde/upstream/how-to/upgrade/) | | Upgrade PostgreSQL from one major version to another on a cluster that does not use `pg_tde` | Use `pg_upgrade` and follow the [major upgrade procedure](https://docs.percona.com/postgresql/18/major-upgrade.html) | | Upgrade Percona PostgreSQL to a newer minor version within the same major version (for example from 18.3 to 18.4) | Follow the [minor upgrade procedure ](https://docs.percona.com/postgresql/18/minor-upgrade.html) | ## Implementation {#implementation} `pg_tde_upgrade` copies the `pg_tde` subdirectory from the old data directory to the new data directory and then runs `pg_upgrade` as normal except for using `pg_tde_resetwal` instead of `pg_resetwal`. > [!NOTE] > Ensure that `pg_tde` is included in `shared_preload_libraries` and that you have the right setting for [`pg_tde.wal_encrypt`](/docs/tde/upstream/variables/#pgtde-walencrypt) in the new cluster. ## Usage {#usage} Use `pg_tde_upgrade` in place of `pg_upgrade` when performing a PostgreSQL major version upgrade on a cluster that uses `pg_tde`. `pg_tde_upgrade` accepts the same command-line arguments as `pg_upgrade`. Example: ```bash pg_tde_upgrade \ --old-bindir ... \ --new-bindir ... \ --old-datadir ... \ --new-datadir ... ``` For more information on how to perform the upgrade for minor versions, see [Minor Upgrade of Percona Distribution for PostgreSQL ](https://docs.percona.com/postgresql/18/minor-upgrade.html?h=pg_tde#before-you-start). For more information on how to perform the upgrade for the `pg_tde` package version, see [Upgrade pg_tde](/docs/tde/upstream/how-to/upgrade/). [PG.CENTER edition](https://github.com/pgsty/doc.pg.center/blob/4410c32dc9186a22859008303f474b72a779f583/content/percona/command-line-tools/pg-tde-upgrade.md) · [Upstream source](https://github.com/percona/pg_tde/blob/5dd7a9e4e3599d88546f5de67ff0f4ef3fe51a9a/documentation/docs/command-line-tools/pg-tde-upgrade.md) --- Backlinks: - [Tool overview](/docs/tde/upstream/command-line-tools/cli-tools/) - [Upgrade pg_tde](/docs/tde/upstream/how-to/upgrade/) - [2.2.0](/docs/tde/upstream/release-notes/release-notes-v2.2.0/) ================ Source: https://mimus.pgsty.com/docs/tde/upstream/release-notes/index.md ================ # Release notes > Release history and upgrade information for pg_tde. --- LLMS index: [llms.txt](/llms.txt) --- > This is the Percona pg_tde 2.3.0 manual. For the paired build, backup tools and major upgrades, see [PG TDE on Mimus](/docs/tde/). Latest: [pg_tde 2.3.0](/docs/tde/upstream/release-notes/release-notes-v2.3.0/), published on November 17, 2026. [PG.CENTER edition](https://github.com/pgsty/doc.pg.center/blob/4410c32dc9186a22859008303f474b72a779f583/content/percona/release-notes/_index.md) · [Upstream source](https://github.com/percona/pg_tde/tree/5dd7a9e4e3599d88546f5de67ff0f4ef3fe51a9a) --- Section pages: - [pg_tde 2.3.0 (2026-11-17)](/docs/tde/upstream/release-notes/release-notes-v2.3.0/): PostgreSQL 19 support and updated WAL diagnostics in pg_tde 2.3.0. - [pg_tde 2.2.2 (2026-08-20)](/docs/tde/upstream/release-notes/release-notes-v2.2.2/): Changes, compatibility notes, and fixes for pg_tde 2.2.2 (2026-08-20). - [pg_tde 2.2.1 (2026-07-06)](/docs/tde/upstream/release-notes/release-notes-v2.2.1/): Changes, compatibility notes, and fixes for pg_tde 2.2.1 (2026-07-06). - [pg_tde 2.2.0 (2026-05-20)](/docs/tde/upstream/release-notes/release-notes-v2.2.0/): Changes, compatibility notes, and fixes for pg_tde 2.2.0 (2026-05-20). - [pg_tde 2.1.2 (2026-03-02)](/docs/tde/upstream/release-notes/release-notes-v2.1.2/): Changes, compatibility notes, and fixes for pg_tde 2.1.2 (2026-03-02). - [pg_tde 2.1.1 (2026-01-22)](/docs/tde/upstream/release-notes/release-notes-v2.1.1/): Changes, compatibility notes, and fixes for pg_tde 2.1.1 (2026-01-22). - [pg_tde 2.1.0 (2025-11-28)](/docs/tde/upstream/release-notes/release-notes-v2.1/): Changes, compatibility notes, and fixes for pg_tde 2.1.0 (2025-11-28). - [pg_tde 2.0.0 (2025-09-01)](/docs/tde/upstream/release-notes/release-notes-v2.0/): Changes, compatibility notes, and fixes for pg_tde 2.0.0 (2025-09-01). - [pg_tde 1.0.0 (2025-06-30)](/docs/tde/upstream/release-notes/release-notes-v1.0/): Changes, compatibility notes, and fixes for pg_tde 1.0.0 (2025-06-30). - [pg_tde Release Candidate 2 (2025-05-29)](/docs/tde/upstream/release-notes/rc2/): Changes, compatibility notes, and fixes for pg_tde Release Candidate 2 (2025-05-29). - [pg_tde Release Candidate 1 (2025-03-27)](/docs/tde/upstream/release-notes/rc/): Changes, compatibility notes, and fixes for pg_tde Release Candidate 1 (2025-03-27). - [pg_tde Beta 2 (2024-12-16)](/docs/tde/upstream/release-notes/beta2/): Changes, compatibility notes, and fixes for pg_tde Beta 2 (2024-12-16). - [pg_tde Beta (2024-06-30)](/docs/tde/upstream/release-notes/beta/): Changes, compatibility notes, and fixes for pg_tde Beta (2024-06-30). - [pg_tde Alpha 1 (2024-03-28)](/docs/tde/upstream/release-notes/alpha1/): Changes, compatibility notes, and fixes for pg_tde Alpha 1 (2024-03-28). - [pg_tde MVP (2023-12-12)](/docs/tde/upstream/release-notes/mvp/): Changes, compatibility notes, and fixes for pg_tde MVP (2023-12-12). - [Percona Transparent Data Encryption for PostgreSQL release notes index](/docs/tde/upstream/release-notes/release-notes/): The upstream release index, with links to version-specific changes. --- Backlinks: - [Percona pg_tde 2.3.0](/docs/tde/upstream/) ================ Source: https://mimus.pgsty.com/docs/tde/upstream/release-notes/release-notes-v2.3.0/index.md ================ # pg_tde 2.3.0 (2026-11-17) > PostgreSQL 19 support and updated WAL diagnostics in pg_tde 2.3.0. --- LLMS index: [llms.txt](/llms.txt) --- > This is the Percona pg_tde 2.3.0 manual. For the paired build, backup tools and major upgrades, see [PG TDE on Mimus](/docs/tde/). > [!NOTE] Release date > The 2.3.0 tag was published on November 17, 2026. The upstream documentation date variable was still `TBD` at this pinned revision. The `pg_tde` extension, provided by Percona, adds [Transparent Data Encryption (TDE)](/docs/tde/upstream/index/about-tde/) to PostgreSQL and helps protect sensitive data at rest. [Get Started](/docs/tde/upstream/install/) ## Release Highlights {#release-highlights} `pg_tde` 2.3.0 adds support for PostgreSQL 19 and makes `pg_tde_waldump` aware of the `pg_tde` custom resource manager. For more details, see the [Changelog](#changelog). ## Known issues {#known-issues} * The default `mlock` limit on Rocky Linux 8 for ARM64-based architectures equals the memory page size and is 64 Kb. This results in the child process with `pg_tde` failing to allocate another memory page because the max memory limit is reached by the parent process. To prevent this, you can change the `mlock` limit to be at least twice the memory page size: * temporarily for the current session using the `ulimit -l ` command. * set a new hard limit in the `/etc/security/limits.conf` file. To do so, you require the superuser privileges. Adjust the limits with caution since it affects other processes running in your system. ## Changelog {#changelog} Changes introduced in `pg_tde` 2.3.0: ### New Features {#new-features} - [PG-2536](https://perconadev.atlassian.net/browse/PG-2536), [PG-2813](https://perconadev.atlassian.net/browse/PG-2813) - Support for PostgreSQL 19 ### Improvements {#improvements} - [PG-2754](https://perconadev.atlassian.net/browse/PG-2754) - `pg_tde_waldump` now recognises the `pg_tde` custom resource manager, prints proper data for its records and accepts it in the `--rmgr` filter [PG.CENTER edition](https://github.com/pgsty/doc.pg.center/blob/4410c32dc9186a22859008303f474b72a779f583/content/percona/release-notes/release-notes-v2.3.0.md) · [Upstream source](https://github.com/percona/pg_tde/blob/5dd7a9e4e3599d88546f5de67ff0f4ef3fe51a9a/documentation/docs/release-notes/release-notes-v2.3.0.md) --- Backlinks: - [Percona pg_tde 2.3.0](/docs/tde/upstream/) - [WAL inspection](/docs/tde/upstream/command-line-tools/pg-tde-waldump/) - [Introduction](/docs/tde/upstream/overview/) - [Release notes](/docs/tde/upstream/release-notes/) - [Upstream release index](/docs/tde/upstream/release-notes/release-notes/) ================ Source: https://mimus.pgsty.com/docs/tde/upstream/release-notes/release-notes-v2.2.2/index.md ================ # pg_tde 2.2.2 (2026-08-20) > Changes, compatibility notes, and fixes for pg_tde 2.2.2 (2026-08-20). --- LLMS index: [llms.txt](/llms.txt) --- > This is the Percona pg_tde 2.3.0 manual. For the paired build, backup tools and major upgrades, see [PG TDE on Mimus](/docs/tde/). The `pg_tde` extension, provided by Percona, adds [Transparent Data Encryption (TDE)](/docs/tde/upstream/index/about-tde/) to PostgreSQL and helps protect sensitive data at rest. [Get Started](/docs/tde/upstream/install/) ## Release Highlights {#release-highlights} `pg_tde` 2.2.2 focuses on fixing an issue with performance of WAL encryption and adding support for KMIP with HashiCorp Vault Enterprise. Vault Enterprise was already supported via the Vault V2 protocol, but now KMIP can be used too. > [!WARNING] > `pg_tde` 2.2.2 is not compatible with Percona Distribution for PostgreSQL older than 17.10.2 or 18.4.2. ## Known issues {#known-issues} * The default `mlock` limit on Rocky Linux 8 for ARM64-based architectures equals the memory page size and is 64 Kb. This results in the child process with `pg_tde` failing to allocate another memory page because the max memory limit is reached by the parent process. To prevent this, you can change the `mlock` limit to be at least twice the memory page size: * temporarily for the current session using the `ulimit -l ` command. * set a new hard limit in the `/etc/security/limits.conf` file. To do so, you require the superuser privileges. Adjust the limits with caution since it affects other processes running in your system. ## Changelog {#changelog} Changes introduced in `pg_tde` 2.2.2: ### New Features {#new-features} - [PG-2125](https://perconadev.atlassian.net/browse/PG-2125) - Support using HashiCorp Vault Enterprise with KMIP - [PG-2473](https://perconadev.atlassian.net/browse/PG-2473) - Basic support for building on Windows with Microsoft Visual C++ ### Improvements {#improvements} - [PG-2494](https://perconadev.atlassian.net/browse/PG-2494) - Improved performance of WAL encryption ### Bug Fixes {#bug-fixes} - [PG-2492](https://perconadev.atlassian.net/browse/PG-2492) - Fixed crash when empty certificate parameters are passed to `pg_tde_add_global_key_provider_kmip()` or `pg_tde_add_database_key_provider_kmip()` - [PG-2608](https://perconadev.atlassian.net/browse/PG-2608) - Fixed a race condition in the Vault key provider that could occur when multiple processes accessed the same cURL handle after a fork. - [PG-2609](https://perconadev.atlassian.net/browse/PG-2609) - Fixed WAL archiving (`pg_tde_archive_decrypt` and `pg_tde_restore_encrypt`) when pg_wal dir is a symlink. - Include bugfixes for frontend tools from PostgreSQL 16.15, 17.11 and 18.5 [PG.CENTER edition](https://github.com/pgsty/doc.pg.center/blob/4410c32dc9186a22859008303f474b72a779f583/content/percona/release-notes/release-notes-v2.2.2.md) · [Upstream source](https://github.com/percona/pg_tde/blob/5dd7a9e4e3599d88546f5de67ff0f4ef3fe51a9a/documentation/docs/release-notes/release-notes-v2.2.2.md) --- Backlinks: - [pg_tde 2.2.2: Vault Enterprise KMIP and faster WAL encryption](/docs/tde/upstream/blog/release/2.2.2/) - [Upstream release index](/docs/tde/upstream/release-notes/release-notes/) - [Documentation errata](/docs/tde/upstream/site/errata/) ================ Source: https://mimus.pgsty.com/docs/tde/upstream/release-notes/release-notes-v2.2.1/index.md ================ # pg_tde 2.2.1 (2026-07-06) > Changes, compatibility notes, and fixes for pg_tde 2.2.1 (2026-07-06). --- LLMS index: [llms.txt](/llms.txt) --- > This is the Percona pg_tde 2.3.0 manual. For the paired build, backup tools and major upgrades, see [PG TDE on Mimus](/docs/tde/). > [!NOTE] Historical release > This page describes this release at publication time. For current deployment requirements, read the [supported versions](/docs/tde/upstream/index/supported-versions/) and [limitations](/docs/tde/upstream/index/tde-limitations/). The `pg_tde` extension, provided by Percona, adds [Transparent Data Encryption (TDE)](/docs/tde/upstream/index/about-tde/) to PostgreSQL and helps protect sensitive data at rest. [Get Started](/docs/tde/upstream/install/) ## Release Highlights {#release-highlights} `pg_tde` 2.2.1 focuses on stability and compatibility improvements. This release improves `pg_rewind` reliability. For more details, see the [Changelog](#changelog). > [!WARNING] > `pg_tde` 2.2.1 is not compatible with Percona Distribution for PostgreSQL older than 17.10.2 or 18.4.2. ## Known issues {#known-issues} * The default `mlock` limit on Rocky Linux 8 for ARM64-based architectures equals the memory page size and is 64 Kb. This results in the child process with `pg_tde` failing to allocate another memory page because the max memory limit is reached by the parent process. To prevent this, you can change the `mlock` limit to be at least twice the memory page size: * temporarily for the current session using the `ulimit -l ` command. * set a new hard limit in the `/etc/security/limits.conf` file. To do so, you require the superuser privileges. Adjust the limits with caution since it affects other processes running in your system. ## Changelog {#changelog} Changes introduced in `pg_tde` 2.2.1: ### New Features {#new-features} - [PG-2398](https://perconadev.atlassian.net/browse/PG-2398) - PostgreSQL 16 support ### Bug Fixes {#bug-fixes} - [PG-2407](https://perconadev.atlassian.net/browse/PG-2407) - Fixed multiple issues affecting `pg_rewind` for `pg_tde` clusters, improving reliability during rewind and recovery operations. - [PG-2258](https://perconadev.atlassian.net/browse/PG-2258) - Fixed "could not find server principal key" error from `pg_tde_basebackup` ### Changes {#changes} - Remove support for building `pg_tde` with `make`, now it can only be built with Meson [PG.CENTER edition](https://github.com/pgsty/doc.pg.center/blob/4410c32dc9186a22859008303f474b72a779f583/content/percona/release-notes/release-notes-v2.2.1.md) · [Upstream source](https://github.com/percona/pg_tde/blob/5dd7a9e4e3599d88546f5de67ff0f4ef3fe51a9a/documentation/docs/release-notes/release-notes-v2.2.1.md) --- Backlinks: - [pg_tde 2.2.1: PostgreSQL 16 support and safer rewind](/docs/tde/upstream/blog/release/2.2.1/) - [Upstream release index](/docs/tde/upstream/release-notes/release-notes/) ================ Source: https://mimus.pgsty.com/docs/tde/upstream/release-notes/release-notes-v2.2.0/index.md ================ # pg_tde 2.2.0 (2026-05-20) > Changes, compatibility notes, and fixes for pg_tde 2.2.0 (2026-05-20). --- LLMS index: [llms.txt](/llms.txt) --- > This is the Percona pg_tde 2.3.0 manual. For the paired build, backup tools and major upgrades, see [PG TDE on Mimus](/docs/tde/). > [!NOTE] Historical release > This page describes this release at publication time. For current deployment requirements, read the [supported versions](/docs/tde/upstream/index/supported-versions/) and [limitations](/docs/tde/upstream/index/tde-limitations/). The `pg_tde` extension, provided by Percona, adds [Transparent Data Encryption (TDE)](/docs/tde/upstream/index/about-tde/) to PostgreSQL and helps protect sensitive data at rest. [Get Started](/docs/tde/upstream/install/) ## Release Highlights {#release-highlights} `pg_tde` now supports 256-bit AES encryption and introduces [`pg_tde_upgrade`](/docs/tde/upstream/command-line-tools/pg-tde-upgrade/), a utility that simplifies the upgrades of encrypted clusters. For more details, see the [Changelog](#changelog). > [!WARNING] > `pg_tde` 2.2.0 is not compatible with Percona Distribution for PostgreSQL older than 17.10 or 18.4. ### Documentation updates {#documentation-updates} * The [Limitations of pg_tde](/docs/tde/upstream/index/tde-limitations/) topic is updated to include a new section on known incompatibilities with Citus and TimescaleDB, and a clarification of the `ALTER DATABASE ... SET TABLESPACE` behavior, the command can be used but with restrictions when `pg_tde` is active. * The [Backup with WAL encryption enabled](/docs/tde/upstream/how-to/backup-wal-enabled/) topic is updated with a clearer description of the key rotation limitation during backups. ## Known issues {#known-issues} * `pg_rewind` and `pg_tde_rewind` Using `pg_rewind` or `pg_tde_rewind` between diverged nodes in clusters that use `pg_tde` may lead to corrupted tables or indexes due to internal encryption key differences between clusters. Queries may fail with: ```bash ERROR: invalid page in block 0 of relation "base/..." ``` This behavior is a known issue. For more information, see [pg_tde limitations](/docs/tde/upstream/index/tde-limitations/). * The default `mlock` limit on Rocky Linux 8 for ARM64-based architectures equals the memory page size and is 64 Kb. This results in the child process with `pg_tde` failing to allocate another memory page because the max memory limit is reached by the parent process. To prevent this, you can change the `mlock` limit to be at least twice the memory page size: * temporarily for the current session using the `ulimit -l ` command. * set a new hard limit in the `/etc/security/limits.conf` file. To do so, you require the superuser privileges. Adjust the limits with caution since it affects other processes running in your system. ## Changelog {#changelog} Changes introduced in `pg_tde` 2.2.0: ### New Features {#new-features} - [PG-1968](https://perconadev.atlassian.net/browse/PG-1968) - AES-256 encryption support, `pg_tde` now supports 256-bit AES encryption, providing stronger cryptographic protection for encrypted tablespaces. - [PG-2017](https://perconadev.atlassian.net/browse/PG-2017) - AES-256 compatibility for `pg_tde_resetwal`, the `pg_tde_resetwal` utility has been updated to work correctly with AES-256 encrypted data. - [PG-2018](https://perconadev.atlassian.net/browse/PG-2018) - AES-256 compatibility for `pg_tde_basebackup`, the `pg_tde_basebackup` utility now fully supports AES-256 encryption, ensuring consistent backup and restore behavior for databases using the new cipher. - [PG-2240](https://perconadev.atlassian.net/browse/PG-2240) - Introducing `pg_tde_upgrade`, a utility that automates the steps required to upgrade a `pg_tde`-enabled cluster, making the upgrade process more convenient. ### Improvements {#improvements} - [PG-2278](https://perconadev.atlassian.net/browse/PG-2278) - Storage manager (SMGR) encryption has been optimized to reuse OpenSSL cipher contexts, reducing overhead and improving throughput for encrypted I/O operations. ### Bug Fixes {#bug-fixes} - [PG-2240](https://perconadev.atlassian.net/browse/PG-2240) - Fixed an issue where `pg_upgrade` would fail when run against databases containing encrypted data. - [PG-1895](https://perconadev.atlassian.net/browse/PG-1895) - Resolved a bug where performing WAL key rotation or SMGR key rotation during a `pg_basebackup` operation could prevent the secondary server from starting successfully. - [PG-2125](https://perconadev.atlassian.net/browse/PG-2125) - Fixed key creation failures that occurred when `pg_tde` was configured to use HashiCorp Vault via the KMIP protocol. [PG.CENTER edition](https://github.com/pgsty/doc.pg.center/blob/4410c32dc9186a22859008303f474b72a779f583/content/percona/release-notes/release-notes-v2.2.0.md) · [Upstream source](https://github.com/percona/pg_tde/blob/5dd7a9e4e3599d88546f5de67ff0f4ef3fe51a9a/documentation/docs/release-notes/release-notes-v2.2.0.md) --- Backlinks: - [Upstream release index](/docs/tde/upstream/release-notes/release-notes/) ================ Source: https://mimus.pgsty.com/docs/tde/upstream/release-notes/release-notes-v2.1.2/index.md ================ # pg_tde 2.1.2 (2026-03-02) > Changes, compatibility notes, and fixes for pg_tde 2.1.2 (2026-03-02). --- LLMS index: [llms.txt](/llms.txt) --- > This is the Percona pg_tde 2.3.0 manual. For the paired build, backup tools and major upgrades, see [PG TDE on Mimus](/docs/tde/). > [!NOTE] Historical release > This page describes this release at publication time. For current deployment requirements, read the [supported versions](/docs/tde/upstream/index/supported-versions/) and [limitations](/docs/tde/upstream/index/tde-limitations/). The `pg_tde` extension, provided by Percona, adds [Transparent Data Encryption (TDE)](/docs/tde/upstream/index/about-tde/) to PostgreSQL and helps protect sensitive data at rest. [Get Started](/docs/tde/upstream/install/) ## Release Highlights {#release-highlights} ### Documentation updates {#documentation-updates} * The [Architecture](/docs/tde/upstream/architecture/overview/) documentation is redesigned for improved clarity and readability. The chapter is now split into smaller, more focused sections. * The [Technical reference overview](/docs/tde/upstream/advanced-topics/tech-reference/) is updated with quick-skim cards for quick topic access. * A dedicated [Usage reference](/docs/tde/upstream/advanced-topics/usage-guide/) topic is introduced which describes the main `pg_tde` operations available. ## Known issues {#known-issues} * `pg_rewind` and `pg_tde_rewind` Using `pg_rewind` or `pg_tde_rewind` between diverged nodes in clusters that use `pg_tde` may lead to corrupted tables or indexes due to internal encryption key differences between clusters. Queries may fail with: ```bash ERROR: invalid page in block 0 of relation "base/..." ``` This behavior is a known issue. For more information, see [pg_tde limitations](/docs/tde/upstream/index/tde-limitations/). * `pg_upgrade` is currently unsupported when `pg_tde` is enabled PostgreSQL clusters that use `pg_tde` cannot currently be upgraded using `pg_upgrade`. * Do not create, change, or rotate global key providers (or their keys) while `pg_tde_basebackup` is running. Doing so may cause standbys or clusters initialized from the backup to fail during WAL replay and may result in corruption of encrypted data (tables, indexes, and other relations). * Using `pg_tde_basebackup` with `--wal-method=fetch` produces warnings. This behavior is expected and will be addressed in a future release. * The default `mlock` limit on Rocky Linux 8 for ARM64-based architectures equals the memory page size and is 64 Kb. This results in the child process with `pg_tde` failing to allocate another memory page because the max memory limit is reached by the parent process. To prevent this, you can change the `mlock` limit to be at least twice bigger than the memory page size: * temporarily for the current session using the `ulimit -l ` command. * set a new hard limit in the `/etc/security/limits.conf` file. To do so, you require the superuser privileges. Adjust the limits with caution since it affects other processes running in your system. ## Changelog {#changelog} ### Improvements {#improvements} * [PG-2088 ](https://perconadev.atlassian.net/browse/PG-2088), [PG-2179 ](https://perconadev.atlassian.net/browse/PG-2179) - Improved handling of Vault/OpenBao KV v2 mount point validation in `pg_tde`. The extension no longer fails when configured with tokens that lack access to mount metadata endpoints and now works correctly with tokens that have only the required KV v2 read/write permissions. ### Bugs Fixed {#bugs-fixed} * Updated `pg_tde` CLI tools to include upstream bug fixes and stability improvements from PostgreSQL 18.2 and 17.8. [PG.CENTER edition](https://github.com/pgsty/doc.pg.center/blob/4410c32dc9186a22859008303f474b72a779f583/content/percona/release-notes/release-notes-v2.1.2.md) · [Upstream source](https://github.com/percona/pg_tde/blob/5dd7a9e4e3599d88546f5de67ff0f4ef3fe51a9a/documentation/docs/release-notes/release-notes-v2.1.2.md) --- Backlinks: - [Upstream release index](/docs/tde/upstream/release-notes/release-notes/) ================ Source: https://mimus.pgsty.com/docs/tde/upstream/release-notes/release-notes-v2.1.1/index.md ================ # pg_tde 2.1.1 (2026-01-22) > Changes, compatibility notes, and fixes for pg_tde 2.1.1 (2026-01-22). --- LLMS index: [llms.txt](/llms.txt) --- > This is the Percona pg_tde 2.3.0 manual. For the paired build, backup tools and major upgrades, see [PG TDE on Mimus](/docs/tde/). > [!NOTE] Historical release > This page describes this release at publication time. For current deployment requirements, read the [supported versions](/docs/tde/upstream/index/supported-versions/) and [limitations](/docs/tde/upstream/index/tde-limitations/). The `pg_tde` extension, provided by Percona, adds [Transparent Data Encryption (TDE)](/docs/tde/upstream/index/about-tde/) to PostgreSQL and helps protect sensitive data at rest. [Get Started](/docs/tde/upstream/install/) ## Release Highlights {#release-highlights} ### Integrated Hashicorp Vault namespace {#integrated-hashicorp-vault-namespace} The namespace of Hashicorp vault is integrated with ``pg_tde`` through the ``pg_tde_add_global_key_provider_vault_v2`` parameter. ### Documentation updates {#documentation-updates} Updated the [Global Principal Key configuration ](/docs/tde/upstream/global-key-provider-configuration/set-principal-key/) and [Configure WAL encryption ](/docs/tde/upstream/wal-encryption/) chapters with updated installation steps and removed outdated KMS configuration information. ## Known issues {#known-issues} * Creating, changing, or rotating global key providers (or their keys) while `pg_tde_basebackup` is running may cause standbys or standalone clusters initialized from the backup to fail during WAL replay and may also lead to the corruption of encrypted data (tables, indexes, and other relations). Avoid making these actions during backup windows. Run a new full backup after completing a rotation or provider update. * Using `pg_tde_basebackup` with `--wal-method=fetch` produces warnings. This behavior is expected and will be addressed in a future release. * The default `mlock` limit on Rocky Linux 8 for ARM64-based architectures equals the memory page size and is 64 Kb. This results in the child process with `pg_tde` failing to allocate another memory page because the max memory limit is reached by the parent process. To prevent this, you can change the `mlock` limit to be at least twice bigger than the memory page size: * temporarily for the current session using the `ulimit -l ` command. * set a new hard limit in the `/etc/security/limits.conf` file. To do so, you require the superuser privileges. Adjust the limits with caution since it affects other processes running in your system. ## Changelog {#changelog} ### New Features {#new-features} * [PG-1959 ](https://perconadev.atlassian.net/browse/PG-1959) - Namespace of Hashicorp vault is integrated with `pg_tde` [PG.CENTER edition](https://github.com/pgsty/doc.pg.center/blob/4410c32dc9186a22859008303f474b72a779f583/content/percona/release-notes/release-notes-v2.1.1.md) · [Upstream source](https://github.com/percona/pg_tde/blob/5dd7a9e4e3599d88546f5de67ff0f4ef3fe51a9a/documentation/docs/release-notes/release-notes-v2.1.1.md) --- Backlinks: - [Upstream release index](/docs/tde/upstream/release-notes/release-notes/) ================ Source: https://mimus.pgsty.com/docs/tde/upstream/release-notes/release-notes-v2.1/index.md ================ # pg_tde 2.1.0 (2025-11-28) > Changes, compatibility notes, and fixes for pg_tde 2.1.0 (2025-11-28). --- LLMS index: [llms.txt](/llms.txt) --- > This is the Percona pg_tde 2.3.0 manual. For the paired build, backup tools and major upgrades, see [PG TDE on Mimus](/docs/tde/). > [!NOTE] Historical release > This page describes this release at publication time. For current deployment requirements, read the [supported versions](/docs/tde/upstream/index/supported-versions/) and [limitations](/docs/tde/upstream/index/tde-limitations/). The `pg_tde` by Percona extension brings [Transparent Data Encryption (TDE)](/docs/tde/upstream/index/about-tde/) to PostgreSQL and enables you to keep sensitive data safe and secure. [Get Started](/docs/tde/upstream/install/) ## Release Highlights {#release-highlights} ### Added support for PostgreSQL 18.1 {#added-support-for-postgresql-18-1} `pg_tde` is fully supported with the Postgres 18.1 version. ### Packaging changes for PostgreSQL 18 {#packaging-changes-for-postgresql-18} Starting with PostgreSQL 18, `pg_tde` is distributed as a **standalone package** for RPM and DEB installations. It is no longer bundled with the main PostgreSQL server package. If your PostgreSQL 18 deployment uses `pg_tde`, make sure to install the matching `pg_tde` package separately. Percona’s PostgreSQL **Docker images continue to include `pg_tde` by default**, so no additional action is required for container-based deployments. For more information on the availability by PostgreSQL version, please see [Install pg_tde](/docs/tde/upstream/install/). ### Added support for AIO {#added-support-for-aio} Added support for **asynchronous I/O (AIO)** which is now the default I/O mechanism. ### Added namespace support for Vault Enterprise and OpenBao {#added-namespace-support-for-vault-enterprise-and-openbao} Added support for HashiCorp Vault and OpenBao namespaces. The `namespace` parameter is now documented in [Add or modify Vault providers](/docs/tde/upstream/functions/#add-or-modify-vault-providers) and fully supported. ### Repository split for multi-version PostgreSQL support {#repository-split-for-multi-version-postgresql-support} Reorganized the project into a multi-repository structure to support several PostgreSQL versions more efficiently. ### Tooling changes {#tooling-changes} The standard PostgreSQL command-line utilities can no longer operate on clusters encrypted with `pg_tde`. To manage encrypted data safely, use the `pg_tde_` equivalents provided by Percona: * pg_basebackup to pg_tde_basebackup * pg_checksums to pg_tde_checksums * pg_resetwal to pg_tde_resetwal * pg_rewind to pg_tde_rewind * pg_waldump to pg_tde_waldump > [!WARNING] > > The non-pg_tde_* versions will not work on encrypted clusters and may fail with errors if used. Always use the `pg_tde_` variants when working with TDE-enabled data. ### Added Akeyless support {#added-akeyless-support} `pg_tde` is now compatible with the Akeyless CipherTrust Manager via the KMIP protocol. For more information, see the [Key management overview topic](/docs/tde/upstream/global-key-provider-configuration/overview/). ### Added support for Vault and OpenBao namespaces {#added-support-for-vault-and-openbao-namespaces} Implemented support for the "namespace" feature in Vault Enterprise and OpenBao, available both on the CLI and on the HTTP interface using the `X-Vault-Namespace` header. ### Documentation updates {#documentation-updates} - Added the [Akeyless topic](/docs/tde/upstream/global-key-provider-configuration/kmip-akeyless/) - Added the [Impact of pg_tde on database operations](/docs/tde/upstream/index/what-tde-impacts/) topic which summarizes how `pg_tde` interacts with core PostgreSQL operations - Updated the [FAQ](/docs/tde/upstream/faq/) with an answer to logical replication keeping data encrypted on subscribers - Updated [Install pg_tde](/docs/tde/upstream/install/) with a table for the `pg_tde` availability by PostgreSQL version - Updated [Add or modify Vault providers](/docs/tde/upstream/functions/#add-or-modify-vault-providers) to include the `namespace` parameter. ## Known issues {#known-issues} * Creating, changing, or rotating global key providers (or their keys) while `pg_tde_basebackup` is running may cause standbys or standalone clusters initialized from the backup to fail during WAL replay and may also lead to the corruption of encrypted data (tables, indexes, and other relations). Avoid making these actions during backup windows. Run a new full backup after completing a rotation or provider update. * Using `pg_tde_basebackup` with `--wal-method=fetch` produces warnings. This behavior is expected and will be addressed in a future release. * The default `mlock` limit on Rocky Linux 8 for ARM64-based architectures equals the memory page size and is 64 Kb. This results in the child process with `pg_tde` failing to allocate another memory page because the max memory limit is reached by the parent process. To prevent this, you can change the `mlock` limit to be at least twice bigger than the memory page size: * temporarily for the current session using the `ulimit -l ` command. * set a new hard limit in the `/etc/security/limits.conf` file. To do so, you require the superuser privileges. Adjust the limits with caution since it affects other processes running in your system. [PG.CENTER edition](https://github.com/pgsty/doc.pg.center/blob/4410c32dc9186a22859008303f474b72a779f583/content/percona/release-notes/release-notes-v2.1.md) · [Upstream source](https://github.com/percona/pg_tde/blob/5dd7a9e4e3599d88546f5de67ff0f4ef3fe51a9a/documentation/docs/release-notes/release-notes-v2.1.md) --- Backlinks: - [Upstream release index](/docs/tde/upstream/release-notes/release-notes/) ================ Source: https://mimus.pgsty.com/docs/tde/upstream/release-notes/release-notes-v2.0/index.md ================ # pg_tde 2.0.0 (2025-09-01) > Changes, compatibility notes, and fixes for pg_tde 2.0.0 (2025-09-01). --- LLMS index: [llms.txt](/llms.txt) --- > This is the Percona pg_tde 2.3.0 manual. For the paired build, backup tools and major upgrades, see [PG TDE on Mimus](/docs/tde/). > [!NOTE] Historical release > This page describes this release at publication time. For current deployment requirements, read the [supported versions](/docs/tde/upstream/index/supported-versions/) and [limitations](/docs/tde/upstream/index/tde-limitations/). The `pg_tde` by Percona extension brings [Transparent Data Encryption (TDE)](/docs/tde/upstream/index/about-tde/) to PostgreSQL and enables you to keep sensitive data safe and secure. [Get Started](/docs/tde/upstream/install/) ## Release Highlights {#release-highlights} ### WAL encryption is now generally available {#wal-encryption-is-now-generally-available} The WAL (Write-Ahead Logging) encryption feature is now fully supported and production-ready, it adds secure write-ahead logging to `pg_tde`, expanding Percona's PostgreSQL encryption coverage by enabling secure, transparent encryption of write-ahead logs using the same key infrastructure as data encryption. ### WAL encryption upgrade limitation {#wal-encryption-upgrade-limitation} Clusters that used WAL encryption in the beta release (`pg_tde` 1.0 or older) cannot be upgraded to `pg_tde` 2.0. The following error indicates that WAL encryption was enabled: ```sql FATAL: principal key not configured HINT: Use pg_tde_set_server_key_using_global_key_provider() to configure one. ``` Clusters that did not use WAL encryption in beta can be upgraded normally. ### Documentation updates {#documentation-updates} * Updated the [Limitations](/docs/tde/upstream/index/tde-limitations/) topic, it now includes WAL encryption limitations and both supported and unsupported WAL tools * [PG-1858 ](https://perconadev.atlassian.net/browse/PG-1858) - Added a new topic for [Backup with WAL encryption enabled](/docs/tde/upstream/how-to/backup-wal-enabled/) that includes restoring a backup created with WAL encryption * [PG-1832 ](https://perconadev.atlassian.net/browse/PG-1858) - Added documentation for using the `pg_tde_archive_decrypt` and `pg_tde_restore_encrypt` utilities. These tools are now covered in [CLI Tools](/docs/tde/upstream/command-line-tools/cli-tools/) to guide users on how to archive and restore encrypted WAL segments securely * [PG-1740 ](https://perconadev.atlassian.net/browse/PG-1740) - Updated documentation for [uninstalling `pg_tde`](/docs/tde/upstream/how-to/uninstall/) with WAL encryption enabled and improved the uninstall instructions to cover cases where TDE is disabled while WAL encryption remains active ## Known issues {#known-issues} * Creating, changing, or rotating global key providers (or their keys) while `pg_basebackup` is running may cause standbys or standalone clusters initialized from the backup to fail during WAL replay and may also lead to the corruption of encrypted data (tables, indexes, and other relations). Avoid making these actions during backup windows. Run a new full backup after completing a rotation or provider update. * Using `pg_basebackup` with `--wal-method=fetch` produces warnings. This behavior is expected and will be addressed in a future release. * The default `mlock` limit on Rocky Linux 8 for ARM64-based architectures equals the memory page size and is 64 Kb. This results in the child process with `pg_tde` failing to allocate another memory page because the max memory limit is reached by the parent process. To prevent this, you can change the `mlock` limit to be at least twice bigger than the memory page size: * temporarily for the current session using the `ulimit -l ` command. * set a new hard limit in the `/etc/security/limits.conf` file. To do so, you require the superuser privileges. Adjust the limits with caution since it affects other processes running in your system. ## Changelog {#changelog} ### New Features {#new-features} * [PG-1497 ](https://perconadev.atlassian.net/browse/PG-1497) WAL encryption is now generally available (GA) * [PG-1037 ](https://perconadev.atlassian.net/browse/PG-1037) - Added support for `pg_rewind` with encrypted WAL * [PG-1411 ](https://perconadev.atlassian.net/browse/PG-1497) - Added support for `pg_resetwal` with encrypted WAL * [PG-1603 ](https://perconadev.atlassian.net/browse/PG-1603) - Added support for `pg_basebackup` with encrypted WAL * [PG-1710 ](https://perconadev.atlassian.net/browse/PG-1710) - Added support for WAL archiving with encrypted WAL * [PG-1711 ](https://perconadev.atlassian.net/browse/PG-1711) - Added support for incremental backups with encrypted WAL, compatibility has been verified with `pg_combinebackup` and the WAL summarizer tool. * [PG-1712 ](https://perconadev.atlassian.net/browse/PG-1712) - Added support for `pg_createsubscriber` with encrypted WAL * [PG-1833 ](https://perconadev.atlassian.net/browse/PG-1833) - Added verified support for using `pg_waldump` with encrypted WAL * [PG-1834 ](https://perconadev.atlassian.net/browse/PG-1834) - Verified `pg_upgrade` with encryption ### Improvements {#improvements} * [PG-1661 ](https://perconadev.atlassian.net/browse/PG-1661) - Added validation for key material received from providers * [PG-1667 ](https://perconadev.atlassian.net/browse/PG-1667) - Validated Vault keyring engine type ### Bugs Fixed {#bugs-fixed} * [PG-1391 ](https://perconadev.atlassian.net/browse/PG-1391) - Fixed unencrypted checkpoint segment on replica with encrypted key * [PG-1412 ](https://perconadev.atlassian.net/browse/PG-1412) – Fixed an issue where `XLogFileCopy` failed with encrypted WAL during PITR and `pg_rewind` * [PG-1452 ](https://perconadev.atlassian.net/browse/PG-1452) - Fixed an issue where `pg_tde_change_key_provider` did not work without the `-D` flag even if `PGDATA` was set * [PG-1485 ](https://perconadev.atlassian.net/browse/PG-1485) - Fixed an issue where streaming replication failed with an invalid magic number in WAL when `wal_encryption` was enabled * [PG-1604 ](https://perconadev.atlassian.net/browse/PG-1604) - Fixed a crash during standby promotion caused by an invalid magic number when replaying two-phase transactions from WAL * [PG-1658 ](https://perconadev.atlassian.net/browse/PG-1658) - Fixed an issue where the global key provider could not be deleted after server restart * [PG-1835 ](https://perconadev.atlassian.net/browse/PG-1835) - Fixed an issue where `pg_resetwal` corrupted encrypted WAL, causing PostgreSQL to fail at startup with an invalid checkpoint * [PG-1842 ](https://perconadev.atlassian.net/browse/PG-1842) - Fixed a delay in replica startup with encrypted tables in streaming replication setups * [PG-1843 ](https://perconadev.atlassian.net/browse/PG-1843) - Fixed performance issues when creating encrypted tables * [PG-1863 ](https://perconadev.atlassian.net/browse/PG-1863) - Fixed an issue where unnecessary WAL was generated when creating temporary tables * [PG-1866 ](https://perconadev.atlassian.net/browse/PG-1866) - Fixed an issue where automatic restart after crash sometimes failed with WAL encryption enabled * [PG-1867 ](https://perconadev.atlassian.net/browse/PG-1867) - Fixed archive recovery with encrypted WAL [PG.CENTER edition](https://github.com/pgsty/doc.pg.center/blob/4410c32dc9186a22859008303f474b72a779f583/content/percona/release-notes/release-notes-v2.0.md) · [Upstream source](https://github.com/percona/pg_tde/blob/5dd7a9e4e3599d88546f5de67ff0f4ef3fe51a9a/documentation/docs/release-notes/release-notes-v2.0.md) --- Backlinks: - [Upstream release index](/docs/tde/upstream/release-notes/release-notes/) ================ Source: https://mimus.pgsty.com/docs/tde/upstream/release-notes/release-notes-v1.0/index.md ================ # pg_tde 1.0.0 (2025-06-30) > Changes, compatibility notes, and fixes for pg_tde 1.0.0 (2025-06-30). --- LLMS index: [llms.txt](/llms.txt) --- > This is the Percona pg_tde 2.3.0 manual. For the paired build, backup tools and major upgrades, see [PG TDE on Mimus](/docs/tde/). > [!NOTE] Historical release > This page describes this release at publication time. For current deployment requirements, read the [supported versions](/docs/tde/upstream/index/supported-versions/) and [limitations](/docs/tde/upstream/index/tde-limitations/). The `pg_tde` by Percona extension brings in [Transparent Data Encryption (TDE) ](/docs/tde/upstream/index/about-tde/) to PostgreSQL and enables you to keep sensitive data safe and secure. [Get Started](/docs/tde/upstream/install/) ## Release Highlights {#release-highlights} * **`pg_tde` 1.0 is now GA (Generally Available)** And **stable** for encrypting relational data in PostgreSQL using [Transparent Data Encryption (TDE) ](/docs/tde/upstream/index/about-tde/). This milestone brings production-level data protection to PostgreSQL workloads. * **WAL encryption is still in Beta** The WAL encryption feature is currently still in beta and is not effective unless explicitly enabled. **It is not yet production ready.** Do **not** enable this feature in production environments. ## Upgrade considerations {#upgrade-considerations} `pg_tde` 1.0 is **not** backward compatible with previous `pg_tde` versions, like Release Candidate 2, due to significant changes in code. This means you **cannot** directly upgrade from one version to another. You must do **a clean installation** of `pg_tde`. ## Known issues {#known-issues} * The default `mlock` limit on Rocky Linux 8 for ARM64-based architectures equals the memory page size and is 64 Kb. This results in the child process with `pg_tde` failing to allocate another memory page because the max memory limit is reached by the parent process. To prevent this, you can change the `mlock` limit to be at least twice bigger than the memory page size: * temporarily for the current session using the `ulimit -l ` command. * set a new hard limit in the `/etc/security/limits.conf` file. To do so, you require the superuser privileges. Adjust the limits with caution since it affects other processes running in your system. ## Changelog {#changelog} ### New Features {#new-features} - [PG-1257 ](https://perconadev.atlassian.net/browse/PG-1257) – Added SQL function to remove the current principal key ### Improvements {#improvements} - [PG-1617 ](https://perconadev.atlassian.net/browse/PG-1617) – Removed relation key cache - [PG-1635 ](https://perconadev.atlassian.net/browse/PG-1635) – User-facing TDE functions now return void - [PG-1605 ](https://perconadev.atlassian.net/browse/PG-1605) – Removed undeclared dependencies for `pg_tde_grant_database_key_management_to_role()` ### Bugs Fixed {#bugs-fixed} - [PG-1581 ](https://perconadev.atlassian.net/browse/PG-1581) – Fixed PostgreSQL crashes on table access when KMIP key is unavailable after restart - [PG-1583 ](https://perconadev.atlassian.net/browse/PG-1583) – Fixed a crash when dropping the `pg_tde` extension with CASCADE after changing the key provider file - [PG-1585 ](https://perconadev.atlassian.net/browse/PG-1585) – Fixed the vault provider re-addition that failed after server restart with a new token - [PG-1592 ](https://perconadev.atlassian.net/browse/PG-1592) – Improve error logs when Server Key Info is requested without being created - [PG-1593 ](https://perconadev.atlassian.net/browse/PG-1593) – Fixed runtime failures when invalid Vault tokens are allowed during key provider creation - [PG-1600 ](https://perconadev.atlassian.net/browse/PG-1600) – Fixed Postmaster error when dropping a table with an unavailable key provider - [PG-1606 ](https://perconadev.atlassian.net/browse/PG-1606) – Fixed missing superuser check in role grant function leads to misleading errors - [PG-1607 ](https://perconadev.atlassian.net/browse/PG-1607) – Improved CA parameter order and surrounding documentation for clearer interpretation - [PG-1608 ](https://perconadev.atlassian.net/browse/PG-1608) – Updated and fixed global key configuration parameters in documentation - [PG-1613 ](https://perconadev.atlassian.net/browse/PG-1613) – Tested and improved the `pg_tde_change_key_provider` CLI utility - [PG-1637 ](https://perconadev.atlassian.net/browse/PG-1637) – Fixed unused keys in key files which caused issues after OID wraparound - [PG-1651 ](https://perconadev.atlassian.net/browse/PG-1651) – Fixed the CLI tool when working with Vault key export/import - [PG-1652 ](https://perconadev.atlassian.net/browse/PG-1652) – Fixed when the server fails to find encryption keys after CLI-based provider change - [PG-1662 ](https://perconadev.atlassian.net/browse/PG-1662) – Fixed the creation of inconsistent encryption status when altering partitioned tables - [PG-1663 ](https://perconadev.atlassian.net/browse/PG-1663) – Fixed the indexes on partitioned tables which were not encrypted - [PG-1700 ](https://perconadev.atlassian.net/browse/PG-1700) – Fixed the error hint when the principal key is missing [PG.CENTER edition](https://github.com/pgsty/doc.pg.center/blob/4410c32dc9186a22859008303f474b72a779f583/content/percona/release-notes/release-notes-v1.0.md) · [Upstream source](https://github.com/percona/pg_tde/blob/5dd7a9e4e3599d88546f5de67ff0f4ef3fe51a9a/documentation/docs/release-notes/release-notes-v1.0.md) --- Backlinks: - [Upstream release index](/docs/tde/upstream/release-notes/release-notes/) ================ Source: https://mimus.pgsty.com/docs/tde/upstream/release-notes/rc2/index.md ================ # pg_tde Release Candidate 2 (2025-05-29) > Changes, compatibility notes, and fixes for pg_tde Release Candidate 2 (2025-05-29). --- LLMS index: [llms.txt](/llms.txt) --- > This is the Percona pg_tde 2.3.0 manual. For the paired build, backup tools and major upgrades, see [PG TDE on Mimus](/docs/tde/). > [!NOTE] Historical release > This page describes this release at publication time. For current deployment requirements, read the [supported versions](/docs/tde/upstream/index/supported-versions/) and [limitations](/docs/tde/upstream/index/tde-limitations/). `pg_tde` extension brings in [Transparent Data Encryption (TDE)](/docs/tde/upstream/index/about-tde/) to PostgreSQL and enables you to keep sensitive data safe and secure. [Get Started](/docs/tde/upstream/install/) ## Release Highlights {#release-highlights} This release provides the following features and improvements: * **Restricted key provider configuration to superusers** The database owners can no longer configure key providers directly. Instead, they must refer to the superuser who manages the provider setup. This security improvement clearly separates the responsibilities between users and administrators. * **WAL encryption supports Vault**. `pg_tde` now supports using the Vault keyring for secure storage and management of WAL encryption keys. * **Automatic WAL internal key generation at server startup**. On each server start, a new internal key is generated for encrypting subsequent WAL records (assuming WAL encryption is enabled). The existing WAL records and their keys remain unchanged, this ensures continuity and secure key management without affecting historical data. * **Proper removal of relation-level encryption keys on table drop** Previously, encrypted relation keys persisted even after dropping the associated tables, potentially leaving orphaned entries in the map file. This is now corrected, when an encrypted table is dropped, its corresponding key is also removed from the key map. * **Fixed external tablespace data loss with encrypted partitions** An issue was fixed where data could be lost when the encrypted partitioned tables were moved to external tablespaces. * **New visibility and verification functions for default principal keys** Added additional functions to help you verify and inspect the state of default principal keys more easily. * **Fixed SQL failures caused by inconsistent key provider switching** An issue was resolved where SQL queries could fail after switching key providers while the server was running. This occurred because principal keys became inaccessible when spread across multiple keyring backends, triggering the single-provider-at-a-time design constraint. `pg_tde` now enforces consistency during provider changes to prevent a corrupted key state and query errors. ## Upgrade considerations {#upgrade-considerations} `pg_tde` Release Candidate 2 is not backward compatible with `pg_tde` Beta2 due to significant changes in code. This means you cannot directly upgrade from one version to another. You must [uninstall](/docs/tde/upstream/how-to/uninstall/) `pg_tde` Beta2 first and then [install](/docs/tde/upstream/install/) and configure the new Release Candidate version. ## Known issues {#known-issues} * The default `mlock` limit on Rocky Linux 8 for ARM64-based architectures equals the memory page size and is 64 Kb. This results in the child process with `pg_tde` failing to allocate another memory page because the max memory limit is reached by the parent process. To prevent this, you can change the `mlock` limit to be at least twice bigger than the memory page size: * temporarily for the current session using the `ulimit -l ` command. * set a new hard limit in the `/etc/security/limits.conf` file. To do so, you require the superuser privileges. Adjust the limits with caution since it affects other processes running in your system. ## Changelog {#changelog} ### New Features {#new-features} * [PG-817](https://perconadev.atlassian.net/browse/PG-817) – Added fuzz testing to `pstress` to strengthen validation and resilience. * [PG-824](https://perconadev.atlassian.net/browse/PG-824) – Ensured fsync is called on `pg_tde.map`, `pg_tde.dat`, and FS key provider files. * [PG-830](https://perconadev.atlassian.net/browse/PG-830) – Implemented full WAL encryption using Vault keyring. * [PG-831](https://perconadev.atlassian.net/browse/PG-831) – Tested WAL recovery and both streaming and logical replication compatibility. * [PG-855](https://perconadev.atlassian.net/browse/PG-855) – Added a contributor guide to help new developers engage with pg_tde. * [PG-938](https://perconadev.atlassian.net/browse/PG-938) – Evaluated use of `pg_basebackup` for automated backup validation with pg_tde. * [PG-962](https://perconadev.atlassian.net/browse/PG-962) – Automated test cases to validate data integrity after PostgreSQL restart. * [PG-1001](https://perconadev.atlassian.net/browse/PG-1001) – Verified encryption behavior of temporary tables. * [PG-1099](https://perconadev.atlassian.net/browse/PG-1099) – Developed automation for bare-metal performance benchmarking. * [PG-1289](https://perconadev.atlassian.net/browse/PG-1289) – Added test cases for verifying compatibility with different PostgreSQL versions. * [PG-1444](https://perconadev.atlassian.net/browse/PG-1444) – Implemented support for removing relation-level encryption keys when dropping tables. * [PG-1455](https://perconadev.atlassian.net/browse/PG-1455) – Introduced random base numbers in encryption IVs for enhanced security. * [PG-1458](https://perconadev.atlassian.net/browse/PG-1458) – Added visibility and verification functions for default principal keys. * [PG-1460](https://perconadev.atlassian.net/browse/PG-1460) – Enabled automatic rotation of WAL internal keys on server start. * [PG-1461](https://perconadev.atlassian.net/browse/PG-1461) – Implemented random IV initialization for WAL keys. * [PG-1506](https://perconadev.atlassian.net/browse/PG-1506) – Added parameter support for client certificates in KMIP provider configuration. ## Improvements {#improvements} * [PG-826](https://perconadev.atlassian.net/browse/PG-826) – Documented how to encrypt and decrypt existing tables using pg_tde. * [PG-827](https://perconadev.atlassian.net/browse/PG-827) – Fixed CI pipeline tests on the smgr branch. * [PG-834](https://perconadev.atlassian.net/browse/PG-834) – Resolved issues with `CREATE ... USING pg_tde` on the smgr branch. * [PG-1427](https://perconadev.atlassian.net/browse/PG-1427) – Tested and fixed KMIP implementation for Thales support. * [PG-1507](https://perconadev.atlassian.net/browse/PG-1507) – Handled ALTER TYPE operations in the TDE event trigger. * [PG-1508](https://perconadev.atlassian.net/browse/PG-1508) – Fixed encryption state inconsistencies when altering inherited tables. * [PG-1550](https://perconadev.atlassian.net/browse/PG-1550) – Restricted database owners from creating key providers to improve security. * [PG-1586](https://perconadev.atlassian.net/browse/PG-1586) – Verified and fixed KMIP compatibility with Fortanix HSM. ### Bugs Fixed {#bugs-fixed} * [PG-1397](https://perconadev.atlassian.net/browse/PG-1397) – Fixed segmentation fault during replication with WAL encryption enabled. * [PG-1413](https://perconadev.atlassian.net/browse/PG-1413) – Resolved invalid WAL magic number errors after toggling encryption. * [PG-1416](https://perconadev.atlassian.net/browse/PG-1416) – Fixed SQL query failures caused by inconsistent key provider switching. * [PG-1468](https://perconadev.atlassian.net/browse/PG-1468) – Fixed WAL read failures on replicas after key rotation. * [PG-1491](https://perconadev.atlassian.net/browse/PG-1491) – Corrected `pg_tde_is_encrypted()` behavior for partitioned tables. * [PG-1493](https://perconadev.atlassian.net/browse/PG-1493) – Fixed data loss when encrypted partitioned tables were moved to external tablespaces. * [PG-1503](https://perconadev.atlassian.net/browse/PG-1503) – Blocked deletion of global key providers still associated with principal keys. * [PG-1504](https://perconadev.atlassian.net/browse/PG-1504) – Ensured correct encryption inheritance in partitioned `tde_heap` tables. * [PG-1510](https://perconadev.atlassian.net/browse/PG-1510) – Used different keys and IVs for PostgreSQL forks to prevent conflicts. * [PG-1530](https://perconadev.atlassian.net/browse/PG-1530) – Fixed inability to read WAL after toggling WAL encryption. * [PG-1532](https://perconadev.atlassian.net/browse/PG-1532) – Resolved errors rewriting owned sequences when pg_tde isn't in the default schema. * [PG-1535](https://perconadev.atlassian.net/browse/PG-1535) – Prevented server crash on calling `pg_tde_principal_key_info()`. * [PG-1537](https://perconadev.atlassian.net/browse/PG-1537) – Fixed crash on NULL input in user-facing functions. * [PG-1539](https://perconadev.atlassian.net/browse/PG-1539) – Handled principal key header verification errors gracefully. * [PG-1540](https://perconadev.atlassian.net/browse/PG-1540) – Ensured sequences are assigned correct encryption status. * [PG-1541](https://perconadev.atlassian.net/browse/PG-1541) – Resolved WAL decryption failure after key rotation. * [PG-1543](https://perconadev.atlassian.net/browse/PG-1543) – Fixed validation error when multiple server keys exist. * [PG-1545](https://perconadev.atlassian.net/browse/PG-1545) – Resolved error from `pg_tde_grant_grant_management_to_role()` execution. * [PG-1546](https://perconadev.atlassian.net/browse/PG-1546) – Fixed incorrect behavior in role grant function. * [PG-1551](https://perconadev.atlassian.net/browse/PG-1551) – Improved handling of short reads and errors in WAL storage code. * [PG-1571](https://perconadev.atlassian.net/browse/PG-1571) – Fixed WAL decryption failure due to corrupted or mismatched principal keys. * [PG-1573](https://perconadev.atlassian.net/browse/PG-1573) – Prevented crash during WAL replay when lock was not held. * [PG-1574](https://perconadev.atlassian.net/browse/PG-1574) – Ensured encrypted WAL is readable by streaming replica. * [PG-1576](https://perconadev.atlassian.net/browse/PG-1576) – Resolved crash from malformed JSON in user-facing functions. [PG.CENTER edition](https://github.com/pgsty/doc.pg.center/blob/4410c32dc9186a22859008303f474b72a779f583/content/percona/release-notes/rc2.md) · [Upstream source](https://github.com/percona/pg_tde/blob/5dd7a9e4e3599d88546f5de67ff0f4ef3fe51a9a/documentation/docs/release-notes/rc2.md) --- Backlinks: - [Upstream release index](/docs/tde/upstream/release-notes/release-notes/) ================ Source: https://mimus.pgsty.com/docs/tde/upstream/release-notes/rc/index.md ================ # pg_tde Release Candidate 1 (2025-03-27) > Changes, compatibility notes, and fixes for pg_tde Release Candidate 1 (2025-03-27). --- LLMS index: [llms.txt](/llms.txt) --- > This is the Percona pg_tde 2.3.0 manual. For the paired build, backup tools and major upgrades, see [PG TDE on Mimus](/docs/tde/). > [!NOTE] Historical release > This page describes this release at publication time. For current deployment requirements, read the [supported versions](/docs/tde/upstream/index/supported-versions/) and [limitations](/docs/tde/upstream/index/tde-limitations/). `pg_tde` extension brings in [Transparent Data Encryption (TDE)](/docs/tde/upstream/index/about-tde/) to PostgreSQL and enables you to keep sensitive data safe and secure. [Get started](/docs/tde/upstream/install/) ## Release Highlights {#release-highlights} This release provides the following features and improvements: * **Improved performance with redesigned WAL encryption**. The approach to WAL encryption has been redesigned. Now, `pg_tde` encrypts entire WAL files starting from the first WAL write after the server was started with the encryption turned on. The information about what is encrypted is stored in the internal key metadata. This change improves WAL encryption flow with native replication and increases performance for large scale databases. * **Default encryption key for single-tenancy**. The new functionality allows you to set a default principal key for the entire database cluster. This key is used to encrypt all databases and tables that do not have a custom principal key set. This feature simplifies encryption configuration and management in single-tenant environments where each user has their own database instance. * **Ability to change key provider configuration** You no longer need to configure a new key provider and set a new principal key if the provider's configuration changed. Now can change the key provider configuration both for the current database and the entire PostgreSQL cluster using [functions](/docs/tde/upstream/functions/#key-provider-management). This enhancement lifts existing limitations and is a native and common way to operate in PostgreSQL. * **Key management permissions** The new functions allow you to manage permissions for global and database key management separately. This feature provides more granular control over key management operations and allows you to delegate key management tasks to different roles. * **Additional information about principal keys and providers** The new functions allow you to display additional information about principal keys and providers. This feature helps you to understand the current key configuration and troubleshoot issues related to key management. * **`tde_heap_basic` access method deprecation** The `tde_heap_basic` access method has limitations in encryption capabilities and affects performance. Also, it poses a potential security risk when used in production environments due to indexes remaining unencrypted. Considering all the above, we decided to deprecate this access method and remove it in future releases. Use the `tde_heap` access method instead that is available with Percona Server for PostgreSQL 17 - a drop-in replacement for PostgreSQL Community. ## Upgrade considerations {#upgrade-considerations} `pg_tde` Release Candidate is not backward compatible with `pg_tde` Beta2 due to significant changes in code. This means you cannot directly upgrade from one version to another. You must [uninstall](/docs/tde/upstream/how-to/uninstall/) `pg_tde` Beta2 first and then [install](/docs/tde/upstream/install/) and configure the new Release Candidate version. ## Known issues {#known-issues} * The default `mlock` limit on Rocky Linux 8 for ARM64-based architectures equals the memory page size and is 64 Kb. This results in the child process with `pg_tde` failing to allocate another memory page because the max memory limit is reached by the parent process. To prevent this, you can change the `mlock` limit to be at least twice bigger than the memory page size: * temporarily for the current session using the `ulimit -l ` command. * set a new hard limit in the `/etc/security/limits.conf` file. To do so, you require the superuser privileges. Adjust the limits with caution since it affects other processes running in your system. * You can now delete global key providers even when their associated principal key is still in use. This known issue will be fixed in the next release. For now, avoid deleting global key providers. ## Changelog {#changelog} ### New Features {#new-features} * [PG-1234](https://perconadev.atlassian.net/browse/PG-1234) - Added functions for separate global and database key management permissions. * [PG-1255](https://perconadev.atlassian.net/browse/PG-1255) - Added functionality to delete key providers. * [PG-1256](https://perconadev.atlassian.net/browse/PG-1256) - Added single-tenant support via the default principal key functionality. * [PG-1258](https://perconadev.atlassian.net/browse/PG-1258) - Added functions to display additional information about principal keys / providers. * [PG-1294](https://perconadev.atlassian.net/browse/PG-1294) - Redesigned WAL encryption. * [PG-1303](https://perconadev.atlassian.net/browse/PG-1303) - Deprecated tde_heap_basic access method. ## Improvements {#improvements} * [PG-858](https://perconadev.atlassian.net/browse/PG-858) - Refactored internal/principal key LWLocks to make local databases inherit a global key provider. * [PG-1243](https://perconadev.atlassian.net/browse/PG-1243) - Investigated performance issues at a specific threshold and large databases and updated documentation about handling hint bits. * [PG-1310](https://perconadev.atlassian.net/browse/PG-1310) - Added access method enforcement via the GUC variable. * [PG-1361](https://perconadev.atlassian.net/browse/PG-1361) - Fixed pg_tde relocatability. * [PG-1380](https://perconadev.atlassian.net/browse/PG-1380) - Added support for `pg_tde_is_encrypted()` function on indexes and sequences. ### Bugs Fixed {#bugs-fixed} * [PG-821](https://perconadev.atlassian.net/browse/PG-821) - Fixed the issue with `pg_basebackup` failing when configuring replication. * [PG-847](https://perconadev.atlassian.net/browse/PG-847) - Fixed the issue with `pg_basebackup` and `pg_checksum` throwing an error on files created by `pg_tde` when the checksum is enabled on the database cluster. * [PG-1004](https://perconadev.atlassian.net/browse/PG-1004) - Fixed the issue with `pg_checksums` utility failing during checksum verification on `pg_tde` tables. Now `pg_checksum` skips encrypted relations by looking if the relation has a custom storage manager (SMGR) key. * [PG-1373](https://perconadev.atlassian.net/browse/PG-1373) - Fixed the issue with potential unterminated strings by using the `memcpy()` or `strlcpy()` instead of the `strncpy()` function. * [PG-1378](https://perconadev.atlassian.net/browse/PG-1378) - Fixed the issue with toast tables created by the `ALTER TABLE` command not being encrypted. * [PG-1379](https://perconadev.atlassian.net/browse/PG-1379) - Fixed sequence and alter table handling in the event trigger. * [PG-1222](https://perconadev.atlassian.net/browse/PG-1222) - Fixed the bug with confused relations with the same `RelFileNumber` in different databases. * [PG-1400](https://perconadev.atlassian.net/browse/PG-1400) - Corrected the pg_tde_change_key_provider naming in help. * [PG-1401](https://perconadev.atlassian.net/browse/PG-1401) - Fixed the issue with inheriting an encryption status during the ALTER TABLE SET access method command execution by basing a new encryption status only on the new encryption setting. * [PG-1414](https://perconadev.atlassian.net/browse/PG-1414) - Fixed the error message wording when configuring WAL encryption by referencing to a correct function. * [PG-1450](https://perconadev.atlassian.net/browse/PG-1450) - Fixed the `pg_tde_delete_key_provider()` function behavior when called multiple times by ignoring already deleted records. * [PG-1451](https://perconadev.atlassian.net/browse/PG-1451) -Fixed the issue with the repeating error message about inability to retrieve a principal key even when a user creates non-encrypted tables by checking the current transaction ID in both the event trigger start function and during a file creation. If the transaction changed during the setup of the current event trigger data, the event trigger is reset. * [PG-1473](https://perconadev.atlassian.net/browse/PG-1473) - Allowed only users with key viewer privileges to execute `pg_tde_verify_principal_key()` and `pg_tde_verify_global_principal_key()` functions. * [PG-1474](https://perconadev.atlassian.net/browse/PG-1474) - Fixed the issue with the principal key reference corruption when reassigning it to a key provider with the same name by setting the key name in vault/kmip getters. * [PG-1476](https://perconadev.atlassian.net [PG.CENTER edition](https://github.com/pgsty/doc.pg.center/blob/4410c32dc9186a22859008303f474b72a779f583/content/percona/release-notes/rc.md) · [Upstream source](https://github.com/percona/pg_tde/blob/5dd7a9e4e3599d88546f5de67ff0f4ef3fe51a9a/documentation/docs/release-notes/rc.md) --- Backlinks: - [The road to the pg_tde release candidate](/docs/tde/upstream/blog/percona/rc-announcement/) - [Upstream release index](/docs/tde/upstream/release-notes/release-notes/) ================ Source: https://mimus.pgsty.com/docs/tde/upstream/release-notes/beta2/index.md ================ # pg_tde Beta 2 (2024-12-16) > Changes, compatibility notes, and fixes for pg_tde Beta 2 (2024-12-16). --- LLMS index: [llms.txt](/llms.txt) --- > This is the Percona pg_tde 2.3.0 manual. For the paired build, backup tools and major upgrades, see [PG TDE on Mimus](/docs/tde/). > [!NOTE] Historical release > This page describes this release at publication time. For current deployment requirements, read the [supported versions](/docs/tde/upstream/index/supported-versions/) and [limitations](/docs/tde/upstream/index/tde-limitations/). `pg_tde` extension brings in [Transparent Data Encryption (TDE)](/docs/tde/upstream/index/about-tde/) to PostgreSQL and enables you to keep sensitive data safe and secure. [Get started](/docs/tde/upstream/install/) > [!IMPORTANT] > > This version of Percona Transparent Data Encryption extension **is > not recommended for production environments yet**. We encourage you to test it and [give your feedback](https://forums.percona.com/c/postgresql/pg-tde-transparent-data-encryption-tde/82). > > This will help us improve the product and make it production-ready faster. ## Release Highlights {#release-highlights} With this release, `pg_tde` extension offers two database specific versions: * PostgreSQL Community version provides only the `tde_heap_basic` access method using which you can introduce table encryption and WAL encryption for data in the encrypted tables. Index data remains unencrypted. * Version for Percona Server for PostgreSQL provides the `tde_heap`access method. using this method you can encrypt index data in encrypted tables thus increasing the safety of your sensitive data. For backward compatibility, the `tde_heap_basic` method is available in this version too. ## Changelog {#changelog} The Beta 2 version introduces the following features and improvements: ### New Features {#new-features} * Added the `tde_heap` access method with which you can now enable index encryption for encrypted tables and global WAL data encryption. To use this access method, you must install Percona Server for PostgreSQL. Check the [installation guide](/docs/tde/upstream/install/) * Added event triggers to identify index creation operations on encrypted tables and store those in a custom storage. * Added support for secure transfer of keys using the [OASIS Key Management Interoperability Protocol (KMIP)](https://docs.oasis-open.org/kmip/kmip-spec/v2.0/os/kmip-spec-v2.0-os.html). The KMIP implementation was tested with the PyKMIP server and the HashiCorp Vault Enterprise KMIP Secrets Engine. ### Improvements {#improvements} * WAL encryption improvements: * Added a global key to encrypt WAL data in global space * Added WAL key management * Keyring improvements: * Renamed functions to point their usage for principal key management * Improved keyring provider management across databases and the global space. * Keyring configuration now uses common JSON API. This simplifies code handling and enables frontend tools like `pg_waldump` to read the code thus improving debugging. * The `pg_tde_is_encrypted` function now supports custom schemas in the format of `pg_tde_is_encrypted('schema.table');` * Changed the location of internal TDE files: instead of the database directory, now all files are stored in ` $PGDATA/pg_tde` * Improved error reporting when `pg_tde` is not added to the `shared_preload_libraries` * Improved memory usage of `tde_heap_basic `during sequential reads * Improved `tde_heap_basic` for select statements * Added encryption support for (some) command line utilities ### Bugs fixed {#bugs-fixed} * Fixed multiple bugs with `tde_heap_basic` and TOAST records * Fixed various memory leaks [PG.CENTER edition](https://github.com/pgsty/doc.pg.center/blob/4410c32dc9186a22859008303f474b72a779f583/content/percona/release-notes/beta2.md) · [Upstream source](https://github.com/percona/pg_tde/blob/5dd7a9e4e3599d88546f5de67ff0f4ef3fe51a9a/documentation/docs/release-notes/beta2.md) --- Backlinks: - [Upstream release index](/docs/tde/upstream/release-notes/release-notes/) ================ Source: https://mimus.pgsty.com/docs/tde/upstream/release-notes/beta/index.md ================ # pg_tde Beta (2024-06-30) > Changes, compatibility notes, and fixes for pg_tde Beta (2024-06-30). --- LLMS index: [llms.txt](/llms.txt) --- > This is the Percona pg_tde 2.3.0 manual. For the paired build, backup tools and major upgrades, see [PG TDE on Mimus](/docs/tde/). > [!NOTE] Historical release > This page describes this release at publication time. For current deployment requirements, read the [supported versions](/docs/tde/upstream/index/supported-versions/) and [limitations](/docs/tde/upstream/index/tde-limitations/). `pg_tde` extension brings in [Transparent Data Encryption (TDE)](/docs/tde/upstream/index/about-tde/) to PostgreSQL and enables you to keep sensitive data safe and secure. [Get started](/docs/tde/upstream/install/) > [!IMPORTANT] > > This version of Percona Transparent Data Encryption extension **is > not recommended for production environments yet**. We encourage you to test it and [give your feedback](https://forums.percona.com/c/postgresql/pg-tde-transparent-data-encryption-tde/82). > > This will help us improve the product and make it production-ready faster. ## Release Highlights {#release-highlights} Starting with `pg_tde` Beta, the access method for `pg_tde` extension is renamed `tde_heap_basic`. Use this access method name to create tables. Find guidelines in [Test TDE](/docs/tde/upstream/test/) tutorial. ## Changelog {#changelog} * Fixed the issue with `pg_tde` running out of memory used for decrypted tuples. The fix introduces the new component `TDEBufferHeapTupleTableSlot` that keeps track of the allocated memory for decrypted tuples and frees this memory when the tuple slot is no longer needed. * Fixed the issue with adjusting a current position in a file by using raw file descriptor for the `lseek` function. (Thanks to user _rainhard_ for providing the fix) * Enhanced the init script to consider a custom superuser for the POSTGRES_USER parameter when `pg_tde` is running via Docker (Thanks to _Alejandro Paredero_ for reporting the issue) [PG.CENTER edition](https://github.com/pgsty/doc.pg.center/blob/4410c32dc9186a22859008303f474b72a779f583/content/percona/release-notes/beta.md) · [Upstream source](https://github.com/percona/pg_tde/blob/5dd7a9e4e3599d88546f5de67ff0f4ef3fe51a9a/documentation/docs/release-notes/beta.md) --- Backlinks: - [Upstream release index](/docs/tde/upstream/release-notes/release-notes/) ================ Source: https://mimus.pgsty.com/docs/tde/upstream/release-notes/alpha1/index.md ================ # pg_tde Alpha 1 (2024-03-28) > Changes, compatibility notes, and fixes for pg_tde Alpha 1 (2024-03-28). --- LLMS index: [llms.txt](/llms.txt) --- > This is the Percona pg_tde 2.3.0 manual. For the paired build, backup tools and major upgrades, see [PG TDE on Mimus](/docs/tde/). > [!NOTE] Historical release > This page describes this release at publication time. For current deployment requirements, read the [supported versions](/docs/tde/upstream/index/supported-versions/) and [limitations](/docs/tde/upstream/index/tde-limitations/). `pg_tde` extension brings in [Transparent Data Encryption (TDE)](/docs/tde/upstream/index/about-tde/) to PostgreSQL and enables you to keep sensitive data safe and secure. [Get started](/docs/tde/upstream/install/) > [!IMPORTANT] > > This version of Percona Transparent Data Encryption extension **is > not recommended for production environments yet**. We encourage you to test it and [give your feedback](https://forums.percona.com/c/postgresql/pg-tde-transparent-data-encryption-tde/82). > > This will help us improve the product and make it production-ready faster. ## Release Highlights {#release-highlights} The Alpha1 version of the extension introduces the following key features: * You can now rotate principal keys used for data encryption. This reduces the risk of long-term exposure to potential attacks and helps you comply with security standards such as GDPR, HIPAA, and PCI DSS. * You can now configure encryption differently for each database. For example, encrypt specific tables in some databases with different encryption keys while keeping others non-encrypted. * Keyring configuration has undergone several improvements, namely: * You can define separate keyring configuration for each database * You can change keyring configuration dynamically, without having to restart the server * The keyring configuration is now stored in a catalog separately for each database, instead of a configuration file * Avoid storing secrets in the unencrypted catalog by configuring keyring parameters to be read from external sources (file, http(s) request) ## Improvements {#improvements} * Renamed the repository and Docker image from `postgres-tde-ext` to `pg_tde`. The extension name remains unchanged * Changed the Initialization Vector (IV) calculation of both the data and internal keys ## Bugs fixed {#bugs-fixed} * Fixed toast related crashes * Fixed a crash with the DELETE statement * Fixed performance-related issues * Fixed a bug where `pg_tde` sent many 404 requests to the Vault server * Fixed сompatibility issues with old OpenSSL versions * Fixed сompatibility with old Curl versions [PG.CENTER edition](https://github.com/pgsty/doc.pg.center/blob/4410c32dc9186a22859008303f474b72a779f583/content/percona/release-notes/alpha1.md) · [Upstream source](https://github.com/percona/pg_tde/blob/5dd7a9e4e3599d88546f5de67ff0f4ef3fe51a9a/documentation/docs/release-notes/alpha1.md) --- Backlinks: - [Upstream release index](/docs/tde/upstream/release-notes/release-notes/) ================ Source: https://mimus.pgsty.com/docs/tde/upstream/release-notes/mvp/index.md ================ # pg_tde MVP (2023-12-12) > Changes, compatibility notes, and fixes for pg_tde MVP (2023-12-12). --- LLMS index: [llms.txt](/llms.txt) --- > This is the Percona pg_tde 2.3.0 manual. For the paired build, backup tools and major upgrades, see [PG TDE on Mimus](/docs/tde/). > [!NOTE] Historical release > This page describes this release at publication time. For current deployment requirements, read the [supported versions](/docs/tde/upstream/index/supported-versions/) and [limitations](/docs/tde/upstream/index/tde-limitations/). The Minimum Viable Product (MVP) version of `pg_tde` introduces the following functionality: * Encryption of heap tables, including TOAST * Encryption keys are stored either in Hashicorp Vault server or in local keyring file (for development) * The key storage is configurable via separate JSON configuration files * Replication support [PG.CENTER edition](https://github.com/pgsty/doc.pg.center/blob/4410c32dc9186a22859008303f474b72a779f583/content/percona/release-notes/mvp.md) · [Upstream source](https://github.com/percona/pg_tde/blob/5dd7a9e4e3599d88546f5de67ff0f4ef3fe51a9a/documentation/docs/release-notes/mvp.md) --- Backlinks: - [Upstream release index](/docs/tde/upstream/release-notes/release-notes/) ================ Source: https://mimus.pgsty.com/docs/tde/upstream/release-notes/release-notes/index.md ================ # Percona Transparent Data Encryption for PostgreSQL release notes index > The upstream release index, with links to version-specific changes. --- LLMS index: [llms.txt](/llms.txt) --- > This is the Percona pg_tde 2.3.0 manual. For the paired build, backup tools and major upgrades, see [PG TDE on Mimus](/docs/tde/). > [!NOTE] Historical release > This page describes this release at publication time. For current deployment requirements, read the [supported versions](/docs/tde/upstream/index/supported-versions/) and [limitations](/docs/tde/upstream/index/tde-limitations/). This page lists all release notes for `pg_tde`, organized by year and version. Use it to track new features, fixes, and updates across major and minor versions. ## 2026 {#2026} * [2.3.0](/docs/tde/upstream/release-notes/release-notes-v2.3.0/) (2026-11-17; upstream date variable pending) * [2.2.2](/docs/tde/upstream/release-notes/release-notes-v2.2.2/) (2026-08-20) * [2.2.1](/docs/tde/upstream/release-notes/release-notes-v2.2.1/) (2026-07-06) * [2.2.0](/docs/tde/upstream/release-notes/release-notes-v2.2.0/) (2026-05-20) * [2.1.2](/docs/tde/upstream/release-notes/release-notes-v2.1.2/) (2026-03-02) * [2.1.1](/docs/tde/upstream/release-notes/release-notes-v2.1.1/) (2026-01-22) ## 2025 {#2025} * [2.1.0](/docs/tde/upstream/release-notes/release-notes-v2.1/) (2025-11-28) * [2.0.0](/docs/tde/upstream/release-notes/release-notes-v2.0/) (2025-09-01) * [1.0.0](/docs/tde/upstream/release-notes/release-notes-v1.0/) (2025-06-30) * [Release Candidate 2 (RC2)](/docs/tde/upstream/release-notes/rc2/) (2025-05-29) * [Release Candidate 1 (RC1)](/docs/tde/upstream/release-notes/rc/) (2025-03-27) ## 2024 {#2024} * [Beta 2](/docs/tde/upstream/release-notes/beta2/) (2024-12-16) * [Beta 1](/docs/tde/upstream/release-notes/beta/) (2024-06-30) * [Alpha 1](/docs/tde/upstream/release-notes/alpha1/) (2024-03-28) ## 2023 {#2023} * [MVP](/docs/tde/upstream/release-notes/mvp/) (2023-12-12) [PG.CENTER edition](https://github.com/pgsty/doc.pg.center/blob/4410c32dc9186a22859008303f474b72a779f583/content/percona/release-notes/release-notes.md) · [Upstream source](https://github.com/percona/pg_tde/blob/5dd7a9e4e3599d88546f5de67ff0f4ef3fe51a9a/documentation/docs/release-notes/release-notes.md) ================ Source: https://mimus.pgsty.com/docs/tde/upstream/faq/index.md ================ # FAQ > Answers about encryption boundaries, recovery, key rotation, and PostgreSQL compatibility. --- LLMS index: [llms.txt](/llms.txt) --- > This is the Percona pg_tde 2.3.0 manual. For the paired build, backup tools and major upgrades, see [PG TDE on Mimus](/docs/tde/). > [!NOTE] Editorial correction > The temporary-file scope and internal-key rotation guidance have been clarified using the current limitations and architecture documentation. Compliance-related statements below reflect the upstream document, not a certification of a particular deployment. See [site errata](/docs/tde/upstream/site/errata/). ## Why do I need TDE? {#why-do-i-need-tde} Using TDE provides the following benefits: - Compliance to security and legal regulations like General Data Protection Regulation (GDPR), Payment Card Industry Data Security Standard (PCI DSS), California Consumer Privacy Act (CCPA), Data Protection Act 2018 (DPA 2018) and others - Encryption of backups. Even when an authorized person gets physical access to a backup, encryption ensures that the data remains unreadable and secure. - Granular encryption of specific data sets and reducing the performance overhead that encryption brings. - Additional layer of security to existing security measures ## When and how should I use TDE? {#when-and-how-should-i-use-tde} If you are dealing with Personally Identifiable Information (PII), data encryption is crucial. Especially if you are involved in areas with strict regulations like: * financial services where TDE helps to comply with PCI DSS * healthcare and insurance - compliance with HIPAA, HITECH, CCPA * telecommunications, government and education to ensure data confidentiality. Using TDE helps you avoid the following risks: * Data breaches * Identity theft that may lead to financial fraud and other crimes * Reputation damage leading to loss of customer trust and business * Legal consequences and financial losses for non-compliance with data protection regulations * Internal threats by misusing unencrypted sensitive data For pg_tde, the encrypted scope includes tables using `tde_heap` and WAL when WAL encryption is enabled. Temporary tables can use `tde_heap`, but temporary files from operations that exceed `work_mem` are **not encrypted**. See the [current limitations](/docs/tde/upstream/index/tde-limitations/). `pg_tde` does not encrypt system catalogs yet. This means that statistics data and database metadata are not encrypted. ## Will logical replication work with pg_tde? {#will-logical-replication-work-with-pgtde} Yes, logical replication works with the encrypted tables. ## Does logical replication keep data encrypted on subscribers? {#does-logical-replication-keep-data-encrypted-on-subscribers} Logical replication **does not** preserve encryption state. If the publisher uses `pg_tde` but the subscriber does not, the replicated data will be stored **in plain text** on the subscriber. Encryption is not propagated to the data-block level due to how logical replication operates. > [!NOTE] > This means encrypted publishers **do not guarantee** encrypted logical replicas. ## I use disk-level encryption. Why should I care about TDE? {#i-use-disk-level-encryption-why-should-i-care-about-tde} Encrypting a hard drive encrypts all data, including system, application, and temporary files. Full disk encryption protects your data from people who have physical access to your device and even if it is lost or stolen. However, it doesn't protect the data after system boot-up: the data is automatically decrypted when the system runs or when an authorized user requests it. Another point to consider is PCI DSS compliance for Personal Account Numbers (PAN) encryption. * **PCI DSS 3.4.1** standards might consider disk encryption sufficient for compliance if you meet these requirements: * Separate the logical data access from the operating system authentication. * Ensure the decryption key is not linked to user accounts. Note that PCI DSS 3.4.1 is retiring on March 31, 2025. Therefore, consider switching to PCI DSS 4.0. * **PCI DSS 4.0** standards consider using only disk and partition-level encryption not enough to ensure PAN protection. It requires an additional layer of security that `pg_tde` can provide. `pg_tde` focuses specifically on data files and offers more granular control over encrypted data. The data remains encrypted on disk during runtime and when you move it to another directory, another system or storage. An example of such data is backups. They remain encrypted when moved to the backup storage. Thus, to protect your sensitive data, consider using TDE to encrypt it at the table level. Then use disk-level encryption to encrypt a specific volume where this data is stored, or the entire disk. ## Is TDE enough to ensure data security? {#is-tde-enough-to-ensure-data-security} **No.** Transparent Data Encryption (TDE) adds an extra layer of security for data at rest. You should also consider implementing the following additional security features: * Access control and authentication * Strong network security like TLS * Disk encryption * Regular monitoring and auditing * Additional data protection for sensitive fields (e.g., application-layer encryption) ## How does pg_tde make my data safe? {#how-does-pgtde-make-my-data-safe} `pg_tde` uses two keys to encrypt data: * Internal encryption keys to encrypt the data. These keys are stored internally in an encrypted format, in a single `$PGDATA/pg_tde` directory. * Principal keys to encrypt internal encryption keys. These keys are stored externally, in the Key Management System (KMS). You can use the following KMSs: * [HashiCorp Vault](https://developer.hashicorp.com/vault/docs/what-is-vault). `pg_tde` supports the KV secrets engine v2 of Vault, for more information see [Vault Configuration](/docs/tde/upstream/global-key-provider-configuration/vault/). * [OpenBao](https://openbao.org/) implementation of Vault * KMIP-compatible servers, KMIP is a standardized protocol for handling cryptographic workloads and secrets management, for more information see [KMIP configuration](/docs/tde/upstream/global-key-provider-configuration/kmip-server/). > [!NOTE] > HashiCorp Vault can also act as a KMIP server, managing cryptographic keys for clients that use the KMIP protocol. > *(KMIP functionality is available in Vault's enterprise edition.)* Let's break the encryption down into two parts: ### Encryption of data files {#encryption-of-data-files} First, data files are encrypted with internal keys. Each file that has a different [Object Identifier (OID)](https://www.postgresql.org/docs/current/datatype-oid.html) has an internal key. For example, a table with 4 indexes will have 5 internal keys - one for the table and one for each index. The initial decision on what file to encrypt is based on the table access method in PostgreSQL. When you run a `CREATE` or `ALTER TABLE` statement with the `USING tde_heap` clause, the newly created data files are marked as encrypted, and then file operations encrypt or decrypt the data. Later, if an initial file is re-created as a result of a `TRUNCATE` or `VACUUM FULL` command, the newly created file inherits the encryption information and is either encrypted or not. The principal key is used to encrypt the internal keys. The principal key is stored in the key management store. When you query the table, the principal key is retrieved from the key store to decrypt the table. Then the internal key for that table is used to decrypt the data. ### WAL encryption {#wal-encryption} WAL encryption is done globally for the entire database cluster. All modifications to any database within a PostgreSQL cluster are written to the same WAL to maintain data consistency and integrity and ensure that PostgreSQL cluster can be restored to a consistent state. Therefore, WAL is encrypted globally. When you turn on WAL encryption, `pg_tde` encrypts entire WAL files starting from the first WAL write after the server was started with the encryption turned on. The same 2-key approach is used with WAL as with the table data: WAL pages are first encrypted with the internal key. Then the internal key is encrypted with the global principal key. You can turn WAL encryption on and off so WAL can contain both encrypted and unencrypted data. The WAL encryption GUC variable influences only writes. Whenever the WAL is being read (by the recovery process or tools), the decision on what should be decrypted is based solely on the metadata of WAL encryption keys. ## Should I encrypt all my data? {#should-i-encrypt-all-my-data} It depends on your business requirements and the sensitivity of your data. Encrypting all data is a good practice but it can have a performance impact. Consider encrypting only tables that store sensitive data. You can decide what tables to encrypt and with what key. The [Set up multi-tenancy](/docs/tde/upstream/how-to/multi-tenant-setup/) section in the documentation focuses on this approach. We advise encrypting the whole database only if all your data is sensitive, like PII, or if there is no other way to comply with data safety requirements. ## What cipher mechanisms are used by pg_tde? {#what-cipher-mechanisms-are-used-by-pgtde} `pg_tde` currently uses the following encryption algorithms: * `AES-128-CBC`, `AES-256-CBC` for encrypting database files; encrypted with internal keys * `AES-128-CTR`, `AES-256-CTR` for WAL encryption; encrypted with internal keys * `AES-128-GCM`, `AES-256-GCM` for encrypting internal keys; encrypted with the principal key ## Is post-quantum encryption supported? {#is-post-quantum-encryption-supported} No, it's not yet supported. In our implementation we reply on OpenSSL libraries that don't yet support post-quantum encryption. ## Can I encrypt an existing table? {#can-i-encrypt-an-existing-table} Yes, you can encrypt an existing table. Run the `ALTER TABLE` command as follows: ```sql ALTER TABLE table_name SET ACCESS METHOD tde_heap; ``` Since the `SET ACCESS METHOD` command drops hint bits and this may affect the performance, we recommend to run the `SELECT count(*)` command. It checks every tuple for visibility and sets its hint bits. Read more in the [Changing existing table](/docs/tde/upstream/test/) section. ## Do I have to restart the database to encrypt the data? {#do-i-have-to-restart-the-database-to-encrypt-the-data} You must restart the database in the following cases to apply the changes: * after you enabled the `pg_tde` extension * when enabling WAL encryption After that, no database restart is required. When you create or alter the table using the `tde_heap` access method, the files are marked as those that require encryption. The encryption happens at the storage manager level, before a transaction is written to disk. Read more about [how tde_heap works](/docs/tde/upstream/index/table-access-method/#how-tdeheap-works-with-pgtde). ## What happens to my data if I lose a principal key? {#what-happens-to-my-data-if-i-lose-a-principal-key} If you lose encryption keys, especially, the principal key, the data is lost. That's why it's critical to back up your encryption keys securely and use the Key Management service for key management. ## Can I use pg_tde in a multi-tenant setup? {#can-i-use-pgtde-in-a-multi-tenant-setup} Multi-tenancy is the type of architecture where multiple users, or tenants, share the same resource. It can be a database, a schema or an entire cluster. In `pg_tde`, multi-tenancy is supported via a separate principal key per database. This means that a database owner can decide what tables to encrypt within a database. The same database can have both encrypted and non-encrypted tables. To control user access to the databases, you can use role-based access control (RBAC). ## Are my backups safe? Can I restore from them? {#are-my-backups-safe-can-i-restore-from-them} `pg_tde` encrypts data at rest. This means that data is stored on disk in an encrypted form. During a backup, already encrypted data files are copied from disk onto the storage. This ensures the data safety in backups. Since the encryption happens on the database level, it makes no difference for your tools and applications. They work with the data in the same way. To restore from an encrypted backup, you must have the same principal encryption key, which was used to encrypt files in your backup. ## I'm using OpenSSL in FIPS mode and need to use pg_tde. Does pg_tde comply with FIPS requirements? Can I use my own FIPS-mode OpenSSL library with pg_tde? {#i-m-using-openssl-in-fips-mode-and-need-to-use-pgtde-does-pgtde-comply-with-fips-requirements-can-i-use-my-own-fips-mode-openssl-library-with-pgtde} Yes. `pg_tde` works with the FIPS-compliant version of OpenSSL, whether it is provided by your operating system or if you use your own OpenSSL libraries. If you use your own libraries, make sure they are FIPS certified. ## How do I rotate internal encryption keys in pg_tde? {#how-do-i-rotate-internal-encryption-keys-in-pgtde} We don't have a dedicated function to rotate internal keys, because a key is effectively rotated any time a table's data file is completely rewritten. Operations like `VACUUM FULL`, `TRUNCATE`, or some but not all `ALTER TABLE` commands automatically generate a new internal key. A table rewrite with `VACUUM FULL` generates a new internal key. Ordinary `VACUUM` does not rewrite the whole table. Plan for the exclusive lock and disk space required by `VACUUM FULL`. ## What tools are supported with `pg_tde` WAL encryption? {#what-tools-are-supported-with-pgtde-wal-encryption} For a comprehensive list of supported `pg_tde` WAL encryption tools see [Limitations of pg_tde](/docs/tde/upstream/index/tde-limitations/). [PG.CENTER edition](https://github.com/pgsty/doc.pg.center/blob/4410c32dc9186a22859008303f474b72a779f583/content/percona/faq.md) · [Upstream source](https://github.com/percona/pg_tde/blob/5dd7a9e4e3599d88546f5de67ff0f4ef3fe51a9a/documentation/docs/faq.md) --- Backlinks: - [2.1.0](/docs/tde/upstream/release-notes/release-notes-v2.1/) - [Documentation errata](/docs/tde/upstream/site/errata/) ================ Source: https://mimus.pgsty.com/docs/tde/upstream/contribute/index.md ================ # Contributing Guide > Build, test, and contribute code or documentation to the upstream pg_tde project. --- LLMS index: [llms.txt](/llms.txt) --- > This is the Percona pg_tde 2.3.0 manual. For the paired build, backup tools and major upgrades, see [PG TDE on Mimus](/docs/tde/). Welcome to `pg_tde` - the Transparent Data Encryption extension for PostgreSQL! We're glad that you would like to become a community member and contribute to this project. You can contribute in one of the following ways: 1. Reach us on our [Forums](https://forums.percona.com/c/postgresql/25). 2. Submit a bug report or a feature request 3. Submit a pull request (PR) with the code patch 4. Contribute to documentation ## Prerequisites {#prerequisites} Before submitting code contributions, we ask you to complete the following prerequisites. ### 1. Sign the CLA {#1-sign-the-cla} Before you can contribute, we kindly ask you to sign our [Contributor License Agreement](https://cla-assistant.percona.com) (CLA). You can do this in on click using your GitHub account. **Note**: You can sign it later, when submitting your first pull request. The CLA assistant validates the PR and asks you to sign the CLA to proceed. ### 2. Code of Conduct {#2-code-of-conduct} Please make sure to read and agree to our [Code of Conduct](https://github.com/percona/community/blob/main/content/contribute/coc.md). ## Submitting a pull request {#submitting-a-pull-request} All bug reports, enhancements and feature requests are tracked in [Jira](https://perconadev.atlassian.net/jira/software/c/projects/PG/issues). Though not mandatory, we encourage you to first check for a bug report among the issues and in the PR list: perhaps the bug has already been addressed. For feature requests and enhancements, we do ask you to create a GitHub issue, describe your idea and discuss the design with us. This way we align your ideas with our vision for the product development. If the bug hasn't been reported / addressed, or we've agreed on the enhancement implementation with you, do the following: 1. [Fork](https://docs.github.com/en/github/getting-started-with-github/fork-a-repo) this repository 2. Clone this repository on your machine. 3. Create a separate branch for your changes. If you work on a Jira issue, please follow this pattern for a branch name: `-name`. This makes it easier to track your contribution. 4. Make your changes. Please follow the following guidelines to improve code readability according to the order listed: - [PostgreSQL coding conventions](https://www.postgresql.org/docs/current/source.html) - [C style and Coding rules](https://github.com/MaJerle/c-code-style) 6. Write the documentation for your changes. See the [Write the docs](#write-the-docs) cheat sheet for details. 7. [Build the code](https://github.com/percona/postgres/wiki/Howtos) and [test your changes locally](#run-local-tests). 8. Commit the changes. The [commit message guidelines](https://gist.github.com/robertpainsi/b632364184e70900af4ab688decf6f53) will help you with writing great commit messages 9. Open a pull request to Percona. 10. Our team will review your code and documentation. If everything is correct, will merge it. Otherwise, we will contact you for additional information or with the request to make changes. ### Run local tests {#run-local-tests} When you work, you should periodically run tests to check that your changes don’t break existing code. To run the tests, use the following command: ```sh ci_scripts/test.sh all ``` You can run tests on your local machine with whatever operating system you have. After you submit the pull request, we will check your patch on multiple operating systems. ## Contribute to documentation {#contribute-to-documentation} `pg_tde` documentation is written in Markdown language, so you can [write the docs for your code changes](#write-the-docs) or [edit the existing documentation online via GitHub](#edit-documentation-online-via-github). If you wish to have more control over the doc process, jump to how to [edit documentation locally](#edit-documentation-locally). Before you start, learn what [Markdown] is and how to write it. For your convenience, there's also a [Markdown cheat sheet](https://daringfireball.net/projects/markdown/syntax) to help you with the syntax. The doc files are in the `documentation/docs` directory. ### Write the docs {#write-the-docs} When you write code, make sure to write documentation that explains it for users. As the author, you know best how your code works. To explain your feature or improvement, use the following key points: 1. Feature Description: What is the feature about, and why does a user need it? 2. User Tasks: What tasks can a user solve with this feature? 3. Functionality: How does the feature work? 4. Setup Requirements: How do you set it up? Are there any preconditions for it to work, such as existing setups or external configurations (e.g., what should be configured in a new Key Management Service - KMS)? 5. Setup Steps: What are the setup steps? Explain the commands and parameters used in functions. Give examples of using them. Provide sample outputs for commands. 6. Limitations and Breaking Changes: Are there any known limitations or breaking changes this feature introduces? ### Edit documentation online via GitHub {#edit-documentation-online-via-github} 1. Click the **Edit this page** icon next to the page title. The source `.md` file of the page opens in GitHub editor in your browser. If you haven’t worked with the repository before, GitHub creates a [fork](https://docs.github.com/en/github/getting-started-with-github/fork-a-repo) of it for you. 2. Edit the page. You can check your changes on the **Preview** tab. 3. Commit your changes. * In the _Commit changes_ section, describe your changes. * Select the **Create a new branch for this commit** and start a pull request option * Click **Propose changes**. 4. GitHub creates a branch and a commit for your changes. It loads a new page on which you can open a pull request to Percona. The page shows the base branch - the one you offer your changes for, your commit message and a diff - a visual representation of your changes against the original page. This allows you to make a last-minute review. When you are ready, click the Create pull request button. 5. Someone from our team reviews the pull request and if everything is correct, merges it into the documentation. Then it gets published on the site. ### Edit documentation locally {#edit-documentation-locally} This option is for users who prefer to work from their computer and / or have the full control over the documentation process. The steps are the following: 1. Fork this repository 2. Clone the repository on your machine: ```sh git clone --recursive git@github.com:/postgres.git ``` 3. Change the directory to `contrib/pg_tde` and add the remote upstream repository: ```sh git remote add upstream git@github.com:percona/postgres.git ``` 4. Pull the latest changes from upstream ```sh git fetch upstream ``` 5. Create a separate branch for your changes ```sh git checkout -b upstream/release-2.3 ``` 6. Make changes 7. Commit your changes. The [commit message guidelines](https://gist.github.com/robertpainsi/b632364184e70900af4ab688decf6f53) will help you with writing great commit messages 8. Open a pull request to Percona #### Building the documentation {#building-the-documentation} To verify how your changes look, generate the static site with the documentation. This process is called *building*. You can do it in these ways: - [Use Docker](#use-docker) - [Install MkDocs and build locally](#install-mkdocs-and-build-locally) ##### Use Docker {#use-docker} 1. [Get Docker](https://docs.docker.com/get-docker/) 2. We use [our Docker image](https://hub.docker.com/repository/docker/perconalab/pmm-doc-md) to build documentation. Run the following command: ```sh cd contrib/pg_tde/documentation docker run --rm -v $(pwd):/docs perconalab/pmm-doc-md mkdocs build ``` If Docker can't find the image locally, it first downloads the image, and then runs it to build the documentation. 3. Go to the ``site`` directory and open the ``index.html`` file to see the documentation. If you want to see the changes as you edit the docs, use this command instead: ```sh cd contrib/pg_tde/documentation docker run --rm -v $(pwd):/docs -p 8000:8000 perconalab/pmm-doc-md mkdocs serve --dev-addr=0.0.0.0:8000 ``` Wait until you see `INFO - Start detecting changes`, then enter `0.0.0.0:8000` in the browser's address bar. The documentation automatically reloads after you save the changes in source files. ##### Install MkDocs and build locally {#install-mkdocs-and-build-locally} 1. Install [Python]. 2. Install MkDocs and required extensions: ```sh pip install -r requirements.txt ``` 3. Build the site: ```sh cd contrib/pg_tde/documentation mkdocs build ``` 4. Open `site/index.html` Or, to run the built-in web server: ```sh cd contrib/pg_tde/documentation mkdocs serve ``` View the site at #### Build PDF file {#build-pdf-file} To build a PDF version of the documentation, do the following: 1. Disable displaying the last modification of the page: ```sh export ENABLED_GIT_REVISION_DATE=false ``` 2. Build the PDF file: ```sh ENABLE_PDF_EXPORT=1 mkdocs build -f mkdocs-pdf.yml ``` The PDF document is in the ``site/pdf`` folder. [MkDocs]: https://www.mkdocs.org/ [Markdown]: https://daringfireball.net/projects/markdown/ [Git]: https://git-scm.com [Python]: https://www.python.org/downloads/ [Docker]: https://docs.docker.com/get-docker/ [PG.CENTER edition](https://github.com/pgsty/doc.pg.center/blob/4410c32dc9186a22859008303f474b72a779f583/content/percona/contribute.md) · [Upstream source](https://github.com/percona/pg_tde/blob/5dd7a9e4e3599d88546f5de67ff0f4ef3fe51a9a/documentation/docs/contribute.md) ================ Source: https://mimus.pgsty.com/docs/tde/upstream/get-help/index.md ================ # Get Help from Percona > Find community discussions, issue reporting, and Percona support channels. --- LLMS index: [llms.txt](/llms.txt) --- > This is the Percona pg_tde 2.3.0 manual. For the paired build, backup tools and major upgrades, see [PG TDE on Mimus](/docs/tde/). Our documentation guides are packed with information, but they can't cover everything you need to know about `pg_tde`. They also won't cover every scenario you might come across. Don't be afraid to try things out and ask questions when you get stuck. ## Percona's Community Forum {#percona-s-community-forum} Be a part of a space where you can tap into a wealth of knowledge from other database enthusiasts and experts who work with Percona's software every day. While our service is entirely free, keep in mind that response times can vary depending on the complexity of the question. You are engaging with people who genuinely love solving database challenges. We recommend visiting our [Community Forum](https://forums.percona.com/t/welcome-to-perconas-community-forum/7). It's an excellent place for discussions, technical insights, and support around Percona database software. If you’re new and feeling a bit unsure, our [FAQ](https://forums.percona.com/faq) and [Guide for New Users](https://forums.percona.com/t/faq-guide-for-new-users/8562) ease you in. If you have thoughts, feedback, or ideas, the community team would like to hear from you at [Any ideas on how to make the forum better?](https://forums.percona.com/t/any-ideas-on-how-to-make-the-forum-better/11522). We’re always excited to connect and improve everyone's experience. ## Percona experts {#percona-experts} Percona experts bring years of experience in tackling tough database performance issues and design challenges. We understand your challenges when managing complex database environments. That's why we offer various services to help you simplify your operations and achieve your goals. | Service | Description | |----------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------| | 24/7 Expert Support | Our dedicated team of database experts is available 24/7 to assist you with any database issues. We provide flexible support plans tailored to your specific needs. | | Hands-On Database Management | Our managed services team can take over the day-to-day management of your database infrastructure, freeing up your time to focus on other priorities. | | Expert Consulting | Our experienced consultants provide guidance on database topics like architecture design, migration planning, performance optimization, and security best practices. | | Comprehensive Training | Our training programs help your team develop skills to manage databases effectively, offering virtual and in-person courses. | We're here to help you every step of the way. Whether you need a quick fix or a long-term partnership, we're ready to provide your expertise and support. [PG.CENTER edition](https://github.com/pgsty/doc.pg.center/blob/4410c32dc9186a22859008303f474b72a779f583/content/percona/get-help.md) · [Upstream source](https://github.com/percona/pg_tde/blob/5dd7a9e4e3599d88546f5de67ff0f4ef3fe51a9a/documentation/docs/get-help.md) --- Backlinks: - [WAL encryption](/docs/tde/upstream/wal-encryption/) ================ Source: https://mimus.pgsty.com/docs/tde/upstream/legal-notice/index.md ================ # Legal notice > The upstream AI chatbot notice, retained for reference; this site does not embed that service. --- LLMS index: [llms.txt](/llms.txt) --- > This is the Percona pg_tde 2.3.0 manual. For the paired build, backup tools and major upgrades, see [PG TDE on Mimus](/docs/tde/). > [!NOTE] Editorial correction > This is the notice for the upstream Percona AI chatbot. This independent documentation site does not embed that chatbot. See [site errata](/docs/tde/upstream/site/errata/). You are interacting with an AI-powered chatbot that provides automated responses for general information about our IT services and software. Responses may be inaccurate or incomplete and do not constitute professional or contractual advice. Do not submit personal data, confidential information, credentials, or other sensitive information through this chat. Conversations may be logged and processed to improve our services in accordance with our [Privacy Policy](https://www.percona.com/privacy-policy#h.c033wws8ytgb) and applicable laws, including the GDPR. If you require assistance, please contact a [human representative](https://www.percona.com/about/contact). [PG.CENTER edition](https://github.com/pgsty/doc.pg.center/blob/4410c32dc9186a22859008303f474b72a779f583/content/percona/legal-notice.md) · [Upstream source](https://github.com/percona/pg_tde/blob/5dd7a9e4e3599d88546f5de67ff0f4ef3fe51a9a/documentation/docs/legal-notice.md) ================ Source: https://mimus.pgsty.com/docs/tde/upstream/site/index.md ================ # About > Source, licence, and maintenance information for the pg_tde documentation site. --- LLMS index: [llms.txt](/llms.txt) --- > This is the Percona pg_tde 2.3.0 manual. For the paired build, backup tools and major upgrades, see [PG TDE on Mimus](/docs/tde/). This site combines the upstream pg_tde documentation with a bilingual Oink reading experience. See the [attribution record](/docs/tde/upstream/site/attribution/). [PG.CENTER edition](https://github.com/pgsty/doc.pg.center/blob/4410c32dc9186a22859008303f474b72a779f583/content/percona/site/_index.md) · [Upstream source](https://github.com/percona/pg_tde/tree/5dd7a9e4e3599d88546f5de67ff0f4ef3fe51a9a) --- Section pages: - [Attribution and copyright](/docs/tde/upstream/site/attribution/): Sources, copyright holders, licence texts and the scope of this independent documentation site. - [Documentation errata](/docs/tde/upstream/site/errata/): Corrections made to the fixed pg_tde documentation snapshot. ================ Source: https://mimus.pgsty.com/docs/tde/upstream/site/attribution/index.md ================ # Attribution and copyright > Sources, copyright holders, licence texts and the scope of this independent documentation site. --- LLMS index: [llms.txt](/llms.txt) --- > This is the Percona pg_tde 2.3.0 manual. For the paired build, backup tools and major upgrades, see [PG TDE on Mimus](/docs/tde/). This is an **independent documentation and translation site maintained by PGSTY**. It is not Percona’s official documentation and does not imply Percona’s endorsement. The [official documentation](/docs/tde/upstream/overview/) and [upstream project](https://github.com/percona/pg_tde) remain the primary sources. ## Documentation source {#documentation-source} The English edition was updated on November 21, 2026 to pg_tde **2.3.0**, at `percona/pg_tde@5dd7a9e4e3599d88546f5de67ff0f4ef3fe51a9a`. It adds the 2.3.0 release notes to the previously imported 66 articles, with section indexes and PGSTY editorial guides. The Chinese edition includes the reviewed 2.3.0 incremental changes. The original authors are Percona and the pg_tde contributors. Read the [source manifest](/docs/tde/upstream/assets/source-manifest.json) for file paths, hashes, supporting assets, and pinned source URLs. Each adapted page links to its original. The [errata](/docs/tde/upstream/site/errata/) records corrections checked against this snapshot. ## Upstream copyright and licence {#upstream-licence} The repository’s [COPYRIGHT](https://github.com/percona/pg_tde/blob/5dd7a9e4e3599d88546f5de67ff0f4ef3fe51a9a/COPYRIGHT) contains the pg_tde licence, with PostgreSQL-style grants and warranty disclaimers. Its full, unmodified text is preserved in [pg_tde-COPYRIGHT.txt](/docs/tde/upstream/assets/legal/pg_tde-COPYRIGHT.txt). It names: - PostgreSQL Global Development Group — portions © 1996–2024. - The Regents of the University of California — portions © 1994. - Percona LLC and/or its affiliates — © 2024–2025. The local identifier `LicenseRef-pg-tde` refers to that exact text. Permission covers use, copying, modification, and distribution of the software and its documentation subject to the stated notices and disclaimers. Percona and PostgreSQL names and logos remain the property of their respective holders. ## Downstream work {#downstream-work} PGSTY converts MkDocs formatting to Hugo/Oink, maintains paired English and Chinese pages, and adds navigation, an original key-hierarchy diagram, a homepage and editorial reading notes. SQL, examples and heading IDs are compared between languages. Corrections are disclosed separately; the source manifest retains the original hashes. Percona blog entries are **short editorial reading notes linking to the original articles**. They retain the original author and publication date. The pg_tde repository licence is not asserted to cover the Percona website’s blog articles. ## Site licence {#site-licence} The original standalone Percona documentation site’s configuration, styles, scripts, diagrams and original editorial text use the [MIT License](/docs/tde/upstream/assets/legal/site-LICENSE.txt). [Oink 1.5.1](https://github.com/pgsty/oink/releases/tag/v1.5.1) supplies the theme under its own licence. Neither changes the upstream documentation licence. [PG.CENTER edition](https://github.com/pgsty/doc.pg.center/blob/4410c32dc9186a22859008303f474b72a779f583/content/percona/site/attribution.md) · [Upstream source](https://github.com/percona/pg_tde/tree/5dd7a9e4e3599d88546f5de67ff0f4ef3fe51a9a) --- Backlinks: - [About](/docs/tde/upstream/site/) - [License and attribution](/license/) ================ Source: https://mimus.pgsty.com/docs/tde/upstream/site/errata/index.md ================ # Documentation errata > Corrections made to the fixed pg_tde documentation snapshot. --- LLMS index: [llms.txt](/llms.txt) --- > This is the Percona pg_tde 2.3.0 manual. For the paired build, backup tools and major upgrades, see [PG TDE on Mimus](/docs/tde/). These corrections apply to the [1660e66a6a30 snapshot](https://github.com/percona/pg_tde/tree/1660e66a6a30d3b8a9020eef7d1fba51bf7e8e39). They are downstream editorial changes, not an assertion that the upstream repository has merged them. Original files remain identifiable by the [source manifest](/docs/tde/upstream/assets/source-manifest.json). | Page | Correction | Evidence | | --- | --- | --- | | [Functions](/docs/tde/upstream/functions/) and [usage reference](/docs/tde/upstream/advanced-topics/usage-guide/) | Use `pg_tde.inherit_global_providers`; remove obsolete parameter names. | [GUC declarations](https://github.com/percona/pg_tde/blob/1660e66a6a30d3b8a9020eef7d1fba51bf7e8e39/src/pg_tde_guc.c) | | [Functions](/docs/tde/upstream/functions/) | `pg_tde_set_key_using_global_key_provider` sets the current database key. The separate server function sets the WAL key. | [Key implementation](https://github.com/percona/pg_tde/blob/1660e66a6a30d3b8a9020eef7d1fba51bf7e8e39/src/catalog/tde_principal_key.c) | | [Usage reference](/docs/tde/upstream/advanced-topics/usage-guide/) | Server/default key setters use global providers; the `(global/database)` notation is invalid for those two functions. | [SQL definitions](https://github.com/percona/pg_tde/blob/1660e66a6a30d3b8a9020eef7d1fba51bf7e8e39/pg_tde--1.0.sql) | | [Restore tool](/docs/tde/upstream/command-line-tools/pg-tde-restore-encrypt/) | `%f` is the WAL file name; `%p` is the destination for the unencrypted WAL segment. | [Built-in help](https://github.com/percona/pg_tde/blob/1660e66a6a30d3b8a9020eef7d1fba51bf7e8e39/src/bin/pg_tde_restore_encrypt.c) | | [Replication](/docs/tde/upstream/replication/) | Create the principal key before assigning it as the server key. | [SQL definitions](https://github.com/percona/pg_tde/blob/1660e66a6a30d3b8a9020eef7d1fba51bf7e8e39/pg_tde--1.0.sql) | | [FAQ](/docs/tde/upstream/faq/) | `work_mem` spill files are not encrypted; ordinary `VACUUM` does not rotate a file’s internal key. Use a table rewrite such as `VACUUM FULL`. | [Limitations](/docs/tde/upstream/index/tde-limitations/) and [architecture](/docs/tde/upstream/architecture/encryption-architecture/) | | [Keyring example](/docs/tde/upstream/global-key-provider-configuration/keyring/) | Inspect `customer_table`, the table actually created; use `pg_tde_key_info()` for the current database key. | [Function reference](/docs/tde/upstream/functions/) | | [KMIP overview](/docs/tde/upstream/global-key-provider-configuration/overview/) | Preserve the older verification wording but flag its difference from the 2.2.2 announcement of Vault Enterprise KMIP support. | [2.2.2 release notes](/docs/tde/upstream/release-notes/release-notes-v2.2.2/) | We also close a missing SQL quote, remove a duplicated RC changelog fragment, repair Markdown links and anchors, and replace MkDocs tabs/callouts with Oink components. Historical releases are labelled by their period. The upstream chatbot and feedback embed are not included. The reproducible English transformations are recorded in `scripts/import_upstream.py` and `scripts/upstream_edits.json`; Chinese counterparts are maintained alongside them. Translation review is a self-review, not an independent certification or a runtime test of pg_tde. [PG.CENTER edition](https://github.com/pgsty/doc.pg.center/blob/4410c32dc9186a22859008303f474b72a779f583/content/percona/site/errata.md) · [Upstream source](https://github.com/percona/pg_tde/tree/5dd7a9e4e3599d88546f5de67ff0f4ef3fe51a9a) --- Backlinks: - [Usage reference](/docs/tde/upstream/advanced-topics/usage-guide/) - [Restore WAL](/docs/tde/upstream/command-line-tools/pg-tde-restore-encrypt/) - [FAQ](/docs/tde/upstream/faq/) - [SQL functions](/docs/tde/upstream/functions/) - [Local keyring](/docs/tde/upstream/global-key-provider-configuration/keyring/) - [KMIP setup](/docs/tde/upstream/global-key-provider-configuration/kmip-server/) - [Choose a provider](/docs/tde/upstream/global-key-provider-configuration/overview/) - [Upstream legal notice](/docs/tde/upstream/legal-notice/) - [Streaming replication](/docs/tde/upstream/replication/) - [Attribution and copyright](/docs/tde/upstream/site/attribution/) ================ Source: https://mimus.pgsty.com/docs/tde/upstream/blog/index.md ================ # Blog > Release notes, architecture notes, and operational guidance for pg_tde. --- LLMS index: [llms.txt](/llms.txt) --- > This is the Percona pg_tde 2.3.0 manual. For the paired build, backup tools and major upgrades, see [PG TDE on Mimus](/docs/tde/). Release notes, architecture explainers, and operational guidance derived from the pg_tde documentation. [PG.CENTER edition](https://github.com/pgsty/doc.pg.center/blob/4410c32dc9186a22859008303f474b72a779f583/content/percona/blog/_index.md) · [Upstream source](https://github.com/percona/pg_tde/tree/5dd7a9e4e3599d88546f5de67ff0f4ef3fe51a9a) --- Section pages: - [Release notes](/docs/tde/upstream/blog/release/): Version announcements and focused upgrade notes for pg_tde. - [Guides](/docs/tde/upstream/blog/guide/): Short, practical guides for designing and operating pg_tde deployments. - [From the Percona blog](/docs/tde/upstream/blog/percona/): Original authors, publication dates and concise bilingual reading notes. ================ Source: https://mimus.pgsty.com/docs/tde/upstream/blog/release/index.md ================ # Release notes > Version announcements and focused upgrade notes for pg_tde. --- LLMS index: [llms.txt](/llms.txt) --- > This is the Percona pg_tde 2.3.0 manual. For the paired build, backup tools and major upgrades, see [PG TDE on Mimus](/docs/tde/). Version announcements and focused upgrade notes for pg_tde. [PG.CENTER edition](https://github.com/pgsty/doc.pg.center/blob/4410c32dc9186a22859008303f474b72a779f583/content/percona/blog/release/_index.md) · [Upstream source](https://github.com/percona/pg_tde/tree/5dd7a9e4e3599d88546f5de67ff0f4ef3fe51a9a) --- Section pages: - [pg_tde 2.2.2: Vault Enterprise KMIP and faster WAL encryption](/docs/tde/upstream/blog/release/2.2.2/): What changed in pg_tde 2.2.2, which Percona PostgreSQL versions are compatible, and what operators should check before upgrading. - [pg_tde 2.2.1: PostgreSQL 16 support and safer rewind](/docs/tde/upstream/blog/release/2.2.1/): The compatibility and reliability changes in pg_tde 2.2.1, with upgrade checks for operators. ================ Source: https://mimus.pgsty.com/docs/tde/upstream/blog/release/2.2.2/index.md ================ # pg_tde 2.2.2: Vault Enterprise KMIP and faster WAL encryption > What changed in pg_tde 2.2.2, which Percona PostgreSQL versions are compatible, and what operators should check before upgrading. --- LLMS index: [llms.txt](/llms.txt) --- > This is the Percona pg_tde 2.3.0 manual. For the paired build, backup tools and major upgrades, see [PG TDE on Mimus](/docs/tde/). An editorial reading note by PGSTY, based on the upstream documentation. pg_tde 2.2.2 focuses on two operator-facing changes: KMIP support for HashiCorp Vault Enterprise and better WAL encryption performance. > [!WARNING] > The upstream release notes state that pg_tde 2.2.2 is incompatible with Percona Distribution for PostgreSQL versions older than 17.10.2 or 18.4.2. ## What changed {#what-changed} - Add support for HashiCorp Vault Enterprise through KMIP. Vault Enterprise was already supported through the Vault V2 protocol. - Improve WAL encryption performance. - Fix empty certificate parameters passed to `pg_tde_add_global_key_provider_kmip()` and `pg_tde_add_database_key_provider_kmip()`. - Fix a Vault provider race after a process fork. - Fix WAL archiving with `pg_tde_archive_decrypt` and `pg_tde_restore_encrypt` when `pg_wal` is a symlink. - Include frontend tool fixes from PostgreSQL 16.15, 17.11, and 18.5. ## Before you upgrade {#before-you-upgrade} 1. Confirm the Percona PostgreSQL package version is compatible. 2. Review the key provider configuration and ensure the server can read existing principal keys. 3. Test WAL archive and restore in a disposable environment. 4. Keep the [backup and WAL encryption procedure](/docs/tde/upstream/how-to/backup-wal-enabled/) with the change record. For the complete upstream changelog, read the [pg_tde 2.2.2 release note](/docs/tde/upstream/release-notes/release-notes-v2.2.2/). [PG.CENTER edition](https://github.com/pgsty/doc.pg.center/blob/4410c32dc9186a22859008303f474b72a779f583/content/percona/blog/release/2.2.2.md) · [Upstream source](https://github.com/percona/pg_tde/blob/5dd7a9e4e3599d88546f5de67ff0f4ef3fe51a9a/documentation/docs/release-notes/release-notes-v2.2.2.md) ================ Source: https://mimus.pgsty.com/docs/tde/upstream/blog/release/2.2.1/index.md ================ # pg_tde 2.2.1: PostgreSQL 16 support and safer rewind > The compatibility and reliability changes in pg_tde 2.2.1, with upgrade checks for operators. --- LLMS index: [llms.txt](/llms.txt) --- > This is the Percona pg_tde 2.3.0 manual. For the paired build, backup tools and major upgrades, see [PG TDE on Mimus](/docs/tde/). An editorial reading note by PGSTY, based on the upstream documentation. pg_tde 2.2.1 is a compatibility and reliability release. ## Highlights {#highlights} - Add PostgreSQL 16 support. - Improve `pg_rewind` behavior for pg_tde clusters. - Fix the `could not find server principal key` error from `pg_tde_basebackup`. - Build pg_tde with Meson; the upstream release no longer supports building it with `make`. ## Upgrade checks {#upgrade-checks} Before upgrading, verify that the target Percona PostgreSQL package and the configured provider can read all existing principal keys. Test rewind, recovery, and backup restore in a staging cluster before changing a production primary. Read the [full 2.2.1 release note](/docs/tde/upstream/release-notes/release-notes-v2.2.1/). [PG.CENTER edition](https://github.com/pgsty/doc.pg.center/blob/4410c32dc9186a22859008303f474b72a779f583/content/percona/blog/release/2.2.1.md) · [Upstream source](https://github.com/percona/pg_tde/blob/5dd7a9e4e3599d88546f5de67ff0f4ef3fe51a9a/documentation/docs/release-notes/release-notes-v2.2.1.md) ================ Source: https://mimus.pgsty.com/docs/tde/upstream/blog/guide/index.md ================ # Guides > Short, practical guides for designing and operating pg_tde deployments. --- LLMS index: [llms.txt](/llms.txt) --- > This is the Percona pg_tde 2.3.0 manual. For the paired build, backup tools and major upgrades, see [PG TDE on Mimus](/docs/tde/). Short, practical guides for designing and operating pg_tde deployments. [PG.CENTER edition](https://github.com/pgsty/doc.pg.center/blob/4410c32dc9186a22859008303f474b72a779f583/content/percona/blog/guide/_index.md) · [Upstream source](https://github.com/percona/pg_tde/tree/5dd7a9e4e3599d88546f5de67ff0f4ef3fe51a9a) --- Section pages: - [A production checklist for pg_tde](/docs/tde/upstream/blog/guide/production-checklist/): The small set of installation, key custody, WAL, backup, and recovery checks to complete before enabling TDE in production. - [How pg_tde keeps data encrypted through PostgreSQL storage](/docs/tde/upstream/blog/guide/encryption-architecture/): A practical tour of tde_heap, the Storage Manager path, internal keys, principal keys, and WAL encryption. ================ Source: https://mimus.pgsty.com/docs/tde/upstream/blog/guide/production-checklist/index.md ================ # A production checklist for pg_tde > The small set of installation, key custody, WAL, backup, and recovery checks to complete before enabling TDE in production. --- LLMS index: [llms.txt](/llms.txt) --- > This is the Percona pg_tde 2.3.0 manual. For the paired build, backup tools and major upgrades, see [PG TDE on Mimus](/docs/tde/). An editorial reading note by PGSTY, based on the upstream documentation. Before enabling encryption, make the key provider and recovery path as concrete as the database configuration. ## Checklist {#checklist} - Confirm the Percona PostgreSQL and pg_tde versions are compatible. - Load `pg_tde` through `shared_preload_libraries` and create the extension in every database that needs it. - Use an external KMS or KMIP-compatible provider for production; keep keyring files for development and testing. - Create and verify a principal key before creating encrypted tables. - Test `tde_heap` on a new table and on a disposable copy of an existing table. - If WAL encryption is enabled, use the pg_tde-aware archive and restore tools. - Back up the provider configuration and document how the server obtains historical keys. - Test restore, replica creation, major upgrade, and provider outage procedures. - Record which objects are outside the encryption scope, including temporary files and statistics. ## Related documentation {#related-documentation} - [Install pg_tde](/docs/tde/upstream/install/) - [Configure key management](/docs/tde/upstream/global-key-provider-configuration/overview/) - [Validate encryption](/docs/tde/upstream/test/) - [Configure WAL encryption](/docs/tde/upstream/wal-encryption/) - [Understand limitations](/docs/tde/upstream/index/tde-limitations/) [PG.CENTER edition](https://github.com/pgsty/doc.pg.center/blob/4410c32dc9186a22859008303f474b72a779f583/content/percona/blog/guide/production-checklist.md) · [Upstream source](https://github.com/percona/pg_tde) ================ Source: https://mimus.pgsty.com/docs/tde/upstream/blog/guide/encryption-architecture/index.md ================ # How pg_tde keeps data encrypted through PostgreSQL storage > A practical tour of tde_heap, the Storage Manager path, internal keys, principal keys, and WAL encryption. --- LLMS index: [llms.txt](/llms.txt) --- > This is the Percona pg_tde 2.3.0 manual. For the paired build, backup tools and major upgrades, see [PG TDE on Mimus](/docs/tde/). An editorial reading note by PGSTY, based on the upstream documentation. Encryption only helps when it follows the real storage path. pg_tde marks the tables that need encryption with `tde_heap`, then uses PostgreSQL's Storage Manager to encrypt pages before they reach disk and decrypt them before they enter the buffer cache. ## The two-key hierarchy {#the-two-key-hierarchy} Each encrypted data file has an internal key. The principal key protects the internal keys and lives in a key provider. This separation lets pg_tde rotate protection without rewriting every data page immediately. ## Where WAL fits {#where-wal-fits} WAL encryption is cluster-wide. The WAL pages use internal keys, and those keys are protected by the server principal key. A WAL reader uses key metadata to decide which records need decryption. ## Operator consequence {#operator-consequence} A table can be readable while its key provider is available and unreadable when the provider or credentials are missing. The [key management guide](/docs/tde/upstream/global-key-provider-configuration/overview/) and [recovery limits](/docs/tde/upstream/index/tde-limitations/) belong in the same runbook as the database configuration. [PG.CENTER edition](https://github.com/pgsty/doc.pg.center/blob/4410c32dc9186a22859008303f474b72a779f583/content/percona/blog/guide/encryption-architecture.md) · [Upstream source](https://github.com/percona/pg_tde/blob/5dd7a9e4e3599d88546f5de67ff0f4ef3fe51a9a/documentation/docs/architecture/encryption-architecture.md) ================ Source: https://mimus.pgsty.com/docs/tde/upstream/blog/percona/index.md ================ # From the Percona blog > Original authors, publication dates and concise bilingual reading notes. --- LLMS index: [llms.txt](/llms.txt) --- > This is the Percona pg_tde 2.3.0 manual. For the paired build, backup tools and major upgrades, see [PG TDE on Mimus](/docs/tde/). Editorial notes and links to original Percona articles. Read the complete articles at the source. [PG.CENTER edition](https://github.com/pgsty/doc.pg.center/blob/4410c32dc9186a22859008303f474b72a779f583/content/percona/blog/percona/_index.md) · [Upstream source](https://github.com/percona/pg_tde/tree/5dd7a9e4e3599d88546f5de67ff0f4ef3fe51a9a) --- Section pages: - [Questions from the PostgreSQL TDE webinar](/docs/tde/upstream/blog/percona/webinar-qa/): The webinar follow-up discusses external key custody, table-level encryption, and the PostgreSQL patches required by pg_tde at the time. It is a useful starting point for separating data encryption from the surrounding access controls and recovery responsibilities. - [The road to the pg_tde release candidate](/docs/tde/upstream/blog/percona/rc-announcement/): The release-candidate announcement explains the move from `tde_heap_basic` to storage-manager integration and the redesign of WAL encryption. It captures a transition: table encryption was approaching GA, while WAL encryption remained a technology preview. - [An early look at pg_tde](/docs/tde/upstream/blog/percona/early-project-update/): This early project update invites testing of an experimental pg_tde and discusses checking whether a table is encrypted. Read it as project history: the access method and SQL interfaces have changed since this prototype. ================ Source: https://mimus.pgsty.com/docs/tde/upstream/blog/percona/webinar-qa/index.md ================ # Questions from the PostgreSQL TDE webinar > The webinar follow-up discusses external key custody, table-level encryption, and the PostgreSQL patches required by pg_tde at the time. It is a useful starting point for separating data encryption from the surrounding access controls and recovery responsibilities. --- LLMS index: [llms.txt](/llms.txt) --- > This is the Percona pg_tde 2.3.0 manual. For the paired build, backup tools and major upgrades, see [PG TDE on Mimus](/docs/tde/). Original author: **Michal Nosek** · Published: **2025-08-13** · Source: [Percona Blog](https://www.percona.com/blog/webinar-qa-no-more-workarounds-open-source-postgresql-tde-is-here/). Reading note by PGSTY. The webinar follow-up discusses external key custody, table-level encryption, and the PostgreSQL patches required by pg_tde at the time. It is a useful starting point for separating data encryption from the surrounding access controls and recovery responsibilities. [Read the complete Percona article](https://www.percona.com/blog/webinar-qa-no-more-workarounds-open-source-postgresql-tde-is-here/). > [!NOTE] Historical article > This article reflects its publication date. For current instructions, consult the [related documentation](/docs/tde/upstream/global-key-provider-configuration/overview/) and [supported versions](/docs/tde/upstream/index/supported-versions/). [PG.CENTER edition](https://github.com/pgsty/doc.pg.center/blob/4410c32dc9186a22859008303f474b72a779f583/content/percona/blog/percona/webinar-qa.md) · [Upstream source](https://github.com/percona/pg_tde/tree/5dd7a9e4e3599d88546f5de67ff0f4ef3fe51a9a) ================ Source: https://mimus.pgsty.com/docs/tde/upstream/blog/percona/rc-announcement/index.md ================ # The road to the pg_tde release candidate > The release-candidate announcement explains the move from `tde_heap_basic` to storage-manager integration and the redesign of WAL encryption. It captures a transition: table encryption was approaching GA, while WAL encryption remained a technology preview. --- LLMS index: [llms.txt](/llms.txt) --- > This is the Percona pg_tde 2.3.0 manual. For the paired build, backup tools and major upgrades, see [PG TDE on Mimus](/docs/tde/). Original author: **Jan Wieremjewicz** · Published: **2025-03-28** · Source: [Percona Blog](https://www.percona.com/blog/transparent-data-encryption-for-postgresql-release-candidate-is-here/). Reading note by PGSTY. The release-candidate announcement explains the move from `tde_heap_basic` to storage-manager integration and the redesign of WAL encryption. It captures a transition: table encryption was approaching GA, while WAL encryption remained a technology preview. [Read the complete Percona article](https://www.percona.com/blog/transparent-data-encryption-for-postgresql-release-candidate-is-here/). > [!NOTE] Historical article > This article reflects its publication date. For current instructions, consult the [related documentation](/docs/tde/upstream/release-notes/rc/) and [supported versions](/docs/tde/upstream/index/supported-versions/). [PG.CENTER edition](https://github.com/pgsty/doc.pg.center/blob/4410c32dc9186a22859008303f474b72a779f583/content/percona/blog/percona/rc-announcement.md) · [Upstream source](https://github.com/percona/pg_tde/tree/5dd7a9e4e3599d88546f5de67ff0f4ef3fe51a9a) ================ Source: https://mimus.pgsty.com/docs/tde/upstream/blog/percona/early-project-update/index.md ================ # An early look at pg_tde > This early project update invites testing of an experimental pg_tde and discusses checking whether a table is encrypted. Read it as project history: the access method and SQL interfaces have changed since this prototype. --- LLMS index: [llms.txt](/llms.txt) --- > This is the Percona pg_tde 2.3.0 manual. For the paired build, backup tools and major upgrades, see [PG TDE on Mimus](/docs/tde/). Original author: **David Stokes** · Published: **2024-01-30** · Source: [Percona Blog](https://www.percona.com/blog/pg_tde-update-perconas-project-to-add-transparent-data-encryption-to-postgresql/). Reading note by PGSTY. This early project update invites testing of an experimental pg_tde and discusses checking whether a table is encrypted. Read it as project history: the access method and SQL interfaces have changed since this prototype. [Read the complete Percona article](https://www.percona.com/blog/pg_tde-update-perconas-project-to-add-transparent-data-encryption-to-postgresql/). > [!NOTE] Historical article > This article reflects its publication date. For current instructions, consult the [related documentation](/docs/tde/upstream/test/) and [supported versions](/docs/tde/upstream/index/supported-versions/). [PG.CENTER edition](https://github.com/pgsty/doc.pg.center/blob/4410c32dc9186a22859008303f474b72a779f583/content/percona/blog/percona/early-project-update.md) · [Upstream source](https://github.com/percona/pg_tde/tree/5dd7a9e4e3599d88546f5de67ff0f4ef3fe51a9a) ================ Source: https://mimus.pgsty.com/docs/spock/index.md ================ # pgEdge > Set up bidirectional active-active logical replication with pgEdge Spock 5.0.15 and understand its recovery boundary. --- LLMS index: [llms.txt](/llms.txt) --- Spock 5.0.15 replicates selected tables between writable PostgreSQL databases. Each node can commit locally and receive the other node’s changes asynchronously. Plan how to identify rows, arbitrate concurrent writes and recover each node before you put a table in a replication set. 1. [Create two nodes and two subscriptions](/docs/spock/two-nodes/). Start with one copy of the initial data. 2. [Choose a conflict policy and monitor apply](/docs/spock/operations/). Check both directions. 3. [Prepare standbys, PITR and rollback](/docs/spock/recovery/). Some conflict resolutions generate WAL that older kernels cannot replay. The integrated replication component is Spock. The Mimus tests exercised two nodes, including encrypted tables and access through the MySQL and TDS clients. Deployment automation, routing and other pgEdge products require their own evaluation. [200 / 201 kernel changes](/docs/reference/patches/spock/) · [Upstream Spock](https://github.com/pgEdge/spock) ## pgEdge extension manuals {#upstream} The [PG.CENTER collection](/docs/spock/upstream/) covers four extensions. The r4 image uses Spock 5.0.15 at `e710faa6fe21`. It also includes LOLOR 1.2.3 and Snowflake 2.6.1. Use the three Mimus guides above to operate that version. | Manual | Upstream reference | Purpose | | --- | --- | --- | | [Spock](/docs/spock/upstream/spock/) | 6.0.0-beta.2 plus 5.0 maintenance notes | Multi-master replication, conflicts, SQL API | | [LOLOR](/docs/spock/upstream/lolor/) | 1.3.0 development snapshot | Logical replication of large objects | | [SafeSession](/docs/spock/upstream/safesession/) | 1.1 | Enforce read-only sessions by role | | [Snowflake](/docs/spock/upstream/snowflake/) | 2.6.1 | Generate distributed 64-bit identifiers | --- Section pages: - [Start two writable nodes](/docs/spock/two-nodes/): Seed the subscriber once, subscribe in reverse and prove that writes arrive in both directions. - [Conflicts, monitoring and catch-up](/docs/spock/operations/): Choose how concurrent writes converge and diagnose a stalled subscription. - [Recovery, failover and rollback](/docs/spock/recovery/): Identify the WAL boundary for physical recovery and the scope of logical fallback. - [pgEdge upstream manuals](/docs/spock/upstream/): Documentation for core pgEdge extensions. --- Backlinks: - [Concepts](/docs/concepts/) - [Migration and operations](/docs/mssql/operations/) - [Parameters & Preload](/docs/reference/configuration/) - [Protocol & Capability Matrix](/docs/reference/matrix/) - [Base · PostgreSQL 19.0](/docs/reference/patches/base/) - [200 / 201 · pgEdge](/docs/reference/patches/spock/) - [pgEdge Suite](/docs/spock/upstream/) - [About this site](/docs/spock/upstream/about/) - [Sources and attribution](/docs/spock/upstream/about/attribution/) - [License texts](/docs/spock/upstream/about/license/) - [Maintenance and coverage](/docs/spock/upstream/about/maintenance/) - [LOLOR](/docs/spock/upstream/lolor/) - [Installing and Configuring lolor](/docs/spock/upstream/lolor/install-configure/) - [lolor Release Notes](/docs/spock/upstream/lolor/lolor-release-notes/) - [Using pg_upgrade with lolor](/docs/spock/upstream/lolor/pg-upgrade-with-lolor/) - [Using lolor](/docs/spock/upstream/lolor/using-lolor/) - [Quick start](/docs/spock/upstream/quick-start/) - [SafeSession](/docs/spock/upstream/safesession/) - [Changelog](/docs/spock/upstream/safesession/changelog/) - [LICENCE()](/docs/spock/upstream/safesession/licence/) - [Snowflake](/docs/spock/upstream/snowflake/) - [Changelog](/docs/spock/upstream/snowflake/changelog/) - [Converting a PostgreSQL Sequence to a Snowflake Sequence](/docs/spock/upstream/snowflake/converting/) - [Creating a Snowflake Sequence in a New Cluster](/docs/spock/upstream/snowflake/creating/) - [Reviewing Sequence Definitions in your Table Meta-data](/docs/spock/upstream/snowflake/review-seq/) - [Snowflake Functions](/docs/spock/upstream/snowflake/snowflake-functions/) - [Spock](/docs/spock/upstream/spock/) - [Configuration](/docs/spock/upstream/spock/configuration/) - [Delta apply](/docs/spock/upstream/spock/conflict-avoidance/) - [Conflict types](/docs/spock/upstream/spock/conflicts/) - [FAQ](/docs/spock/upstream/spock/faq/) - [Getting started](/docs/spock/upstream/spock/getting-started/) - [Installation](/docs/spock/upstream/spock/installation/) - [Internals](/docs/spock/upstream/spock/internals-doc/) - [Design decisions](/docs/spock/upstream/spock/internals-doc/design/) - [spock Output Plugin](/docs/spock/upstream/spock/internals-doc/output/) - [Historical plans](/docs/spock/upstream/spock/internals-doc/plans/) - [remote_commit_ts Recovery via pg_commit_ts Scan — Implementation Plan](/docs/spock/upstream/spock/internals-doc/plans/2026-04-30-recover-remote-commit-ts-plan/) - [Spock Protocol](/docs/spock/upstream/spock/internals-doc/protocol/) - [Design proposals](/docs/spock/upstream/spock/internals-doc/specs/) - [Spock Node Monitoring: Design of the spock_monitor subsystem](/docs/spock/upstream/spock/internals-doc/specs/spock-monitor-design/) - [Eliminating the Spock checkpoint hook and per-commit WAL flush for spock.progress](/docs/spock/upstream/spock/internals-doc/specs/spock-progress-no-checkpoint-hook-design/) - [Limitations](/docs/spock/upstream/spock/limitations/) - [Slot failover](/docs/spock/upstream/spock/logical-slot-failover/) - [Managing replication](/docs/spock/upstream/spock/managing/) - [Filtering](/docs/spock/upstream/spock/managing/filtering/) - [Using LOLOR to Manage Large objects](/docs/spock/upstream/spock/managing/lolor/) - [Replicating Partitioned Tables](/docs/spock/upstream/spock/managing/partition-mgmt/) - [Using Spock in Read-Only Mode](/docs/spock/upstream/spock/managing/read-only/) - [Automatically Assigning Tables to Replication Sets](/docs/spock/upstream/spock/managing/repset-trigger/) - [Using Spock with Snowflake Sequences](/docs/spock/upstream/spock/managing/snowflake/) - [Automatic DDL Replication](/docs/spock/upstream/spock/managing/spock-autoddl/) - [Changing the cluster](/docs/spock/upstream/spock/modify/) - [Adding a Node with pgBackRest](/docs/spock/upstream/spock/modify/add-node-pgbackrest/) - [Tutorial: Upgrading the Postgres Version In Place with pg_upgrade](/docs/spock/upstream/spock/modify/pg-upgrade-rolling-tutorial/) - [Z0DAN](/docs/spock/upstream/spock/modify/zodan/) - [Zodan: Zero-Downtime Node Addition for Spock](/docs/spock/upstream/spock/modify/zodan/zodan-readme/) - [Tutorial: Updating the Postgres Version with a Rolling Update](/docs/spock/upstream/spock/modify/zodan/zodan-rolling-pg-version-tutorial/) - [Tutorial: Adding a Node to a Cluster with Zero Downtime](/docs/spock/upstream/spock/modify/zodan/zodan-tutorial/) - [Monitoring](/docs/spock/upstream/spock/monitoring/) - [Lag Tracking](/docs/spock/upstream/spock/monitoring/lag-tracking/) - [Monitoring a Node with the Spock Status Views](/docs/spock/upstream/spock/monitoring/node-monitoring/) - [Finding Cluster Information](/docs/spock/upstream/spock/monitoring/spock-info/) - [Using spock.sync_event to Confirm Synchronization](/docs/spock/upstream/spock/monitoring/spock-sync-event/) - [pglogical to Spock function names](/docs/spock/upstream/spock/pgl-cheat-sheet/) - [Recovery](/docs/spock/upstream/spock/recovery/) - [Recovering from Catastrophic Node Failure](/docs/spock/upstream/spock/recovery/catastrophic-node-failure/) - [Functions](/docs/spock/upstream/spock/reference/) - [Function reference](/docs/spock/upstream/spock/reference/functions/) - [spock.cleanup_resolutions](/docs/spock/upstream/spock/reference/functions/spock-cleanup-resolutions/) - [spock.gen_slot_name()](/docs/spock/upstream/spock/reference/functions/spock-gen-slot-name/) - [spock.get_country()](/docs/spock/upstream/spock/reference/functions/spock-get-country/) - [spock.max_proto_version()](/docs/spock/upstream/spock/reference/functions/spock-max-proto-version/) - [spock.min_proto_version()](/docs/spock/upstream/spock/reference/functions/spock-min-proto-version/) - [spock.node_add_interface()](/docs/spock/upstream/spock/reference/functions/spock-node-add-interface/) - [spock.node_alter()](/docs/spock/upstream/spock/reference/functions/spock-node-alter/) - [spock.node_create()](/docs/spock/upstream/spock/reference/functions/spock-node-create/) - [spock.node_drop()](/docs/spock/upstream/spock/reference/functions/spock-node-drop/) - [spock.node_drop_interface()](/docs/spock/upstream/spock/reference/functions/spock-node-drop-interface/) - [spock.node_info()](/docs/spock/upstream/spock/reference/functions/spock-node-info/) - [spock.node_refresh_info()](/docs/spock/upstream/spock/reference/functions/spock-node-refresh-info/) - [spock.replicate_ddl()](/docs/spock/upstream/spock/reference/functions/spock-replicate-ddl/) - [spock.repset_add_all_seqs()](/docs/spock/upstream/spock/reference/functions/spock-repset-add-all-seqs/) - [spock.repset_add_all_tables()](/docs/spock/upstream/spock/reference/functions/spock-repset-add-all-tables/) - [spock.repset_add_partition()](/docs/spock/upstream/spock/reference/functions/spock-repset-add-partition/) - [spock.repset_add_seq()](/docs/spock/upstream/spock/reference/functions/spock-repset-add-seq/) - [spock.repset_add_table()](/docs/spock/upstream/spock/reference/functions/spock-repset-add-table/) - [spock.repset_alter()](/docs/spock/upstream/spock/reference/functions/spock-repset-alter/) - [spock.repset_create()](/docs/spock/upstream/spock/reference/functions/spock-repset-create/) - [spock.repset_drop()](/docs/spock/upstream/spock/reference/functions/spock-repset-drop/) - [spock.repset_remove_partition()](/docs/spock/upstream/spock/reference/functions/spock-repset-remove-partition/) - [spock.repset_remove_seq()](/docs/spock/upstream/spock/reference/functions/spock-repset-remove-seq/) - [spock.repset_remove_table()](/docs/spock/upstream/spock/reference/functions/spock-repset-remove-table/) - [spock.repset_show_table()](/docs/spock/upstream/spock/reference/functions/spock-repset-show-table/) - [spock.sub_add_repset()](/docs/spock/upstream/spock/reference/functions/spock-sub-add-repset/) - [spock.sub_alter_interface()](/docs/spock/upstream/spock/reference/functions/spock-sub-alter-interface/) - [spock.sub_alter_options()](/docs/spock/upstream/spock/reference/functions/spock-sub-alter-options/) - [spock.sub_alter_skiplsn()](/docs/spock/upstream/spock/reference/functions/spock-sub-alter-skiplsn/) - [spock.sub_alter_sync](/docs/spock/upstream/spock/reference/functions/spock-sub-alter-sync/) - [spock.sub_create()](/docs/spock/upstream/spock/reference/functions/spock-sub-create/) - [spock.sub_disable](/docs/spock/upstream/spock/reference/functions/spock-sub-disable/) - [spock.sub_drop()](/docs/spock/upstream/spock/reference/functions/spock-sub-drop/) - [spock.sub_enable](/docs/spock/upstream/spock/reference/functions/spock-sub-enable/) - [spock.sub_remove_repset](/docs/spock/upstream/spock/reference/functions/spock-sub-remove-repset/) - [spock.sub_resync_table](/docs/spock/upstream/spock/reference/functions/spock-sub-resync-table/) - [spock.sub_show_status](/docs/spock/upstream/spock/reference/functions/spock-sub-show-status/) - [spock.sub_show_table](/docs/spock/upstream/spock/reference/functions/spock-sub-show-table/) - [spock.sub_wait_for_sync](/docs/spock/upstream/spock/reference/functions/spock-sub-wait-for-sync/) - [spock.sync_event](/docs/spock/upstream/spock/reference/functions/spock-sync-event/) - [spock.sync_seq](/docs/spock/upstream/spock/reference/functions/spock-sync-seq/) - [spock.table_wait_for_sync()](/docs/spock/upstream/spock/reference/functions/spock-table-wait-for-sync/) - [spock.version()](/docs/spock/upstream/spock/reference/functions/spock-version/) - [spock.version_num()](/docs/spock/upstream/spock/reference/functions/spock-version-num/) - [spock.wait_slot_confirm_lsn()](/docs/spock/upstream/spock/reference/functions/spock-wait-slot-confirm-lsn/) - [spock.xact_commit_timestamp_origin()](/docs/spock/upstream/spock/reference/functions/spock-xact-commit-timestamp-origin/) - [Management Functions](/docs/spock/upstream/spock/reference/gen-mgmt/) - [Node Management](/docs/spock/upstream/spock/reference/node-mgmt/) - [Replication Set Management](/docs/spock/upstream/spock/reference/repset-mgmt/) - [Subscription Management Functions](/docs/spock/upstream/spock/reference/sub-mgmt/) - [Resource sizing](/docs/spock/upstream/spock/sizing/) - [Release notes](/docs/spock/upstream/spock/spock-release-notes/) - [Troubleshooting](/docs/spock/upstream/spock/troubleshooting/) - [Two-node tutorial](/docs/spock/upstream/spock/two-node/) - [Upgrading](/docs/spock/upstream/spock/upgrading/) - [Active-Active Nodes](/docs/tutorials/active-active-nodes/) ================ Source: https://mimus.pgsty.com/docs/spock/two-nodes/index.md ================ # Start two writable nodes > Seed the subscriber once, subscribe in reverse and prove that writes arrive in both directions. --- LLMS index: [llms.txt](/llms.txt) --- ## Prepare the instances {#prepare} Start with two fresh Mimus 19.0.1 clusters on one host, A on loopback port 5541 and B on 5542. Install the paired Spock extension and output plugin in both prefixes. Configure the following on **both**, merging any existing required preloads. Each cluster needs its own data directory and port. Restart both and create a database named `lab` in each. For separate hosts replace the loopback addresses with peer-reachable addresses. ```ini shared_preload_libraries = 'spock' wal_level = logical track_commit_timestamp = on output_plugin_libraries = 'pgoutput,spock_output' max_worker_processes = 24 max_replication_slots = 12 max_wal_senders = 12 spock.conflict_resolution = 'last_update_wins' spock.save_resolutions = on spock.enable_ddl_replication = off ``` Configure `pg_hba.conf` and service-account libpq credentials so both servers can connect to both `lab` databases using the named administrative role. The example uses `postgres`. Test each DSN from the database service account, including reconnect after restart. Connect `psql` to `lab` separately on A and B. Install the extension on both, then register each node with its own address. ```sql -- A and B CREATE EXTENSION spock; -- A SELECT spock.node_create('node_a', 'host=127.0.0.1 port=5541 dbname=lab user=postgres'); -- B SELECT spock.node_create('node_b', 'host=127.0.0.1 port=5542 dbname=lab user=postgres'); ``` ## Define the tables and copy the seed {#subscribe} On **both** nodes create the same empty table, column options and replication-set membership: ```sql CREATE TABLE public.accounts ( id integer PRIMARY KEY, label text, balance integer NOT NULL ); ALTER TABLE public.accounts ALTER COLUMN balance SET (log_old_value = true, delta_apply_function = spock.delta_apply); SELECT spock.repset_add_table('default', 'public.accounts'); ``` Seed A only. On B, subscribe to A and confirm the seed arrived. Then subscribe A to B without copying data a second time. The empty origin list limits forwarding to locally originated changes. ```sql -- A INSERT INTO public.accounts VALUES (1, 'seed', 100); -- B SELECT spock.sub_create('from_a', 'host=127.0.0.1 port=5541 dbname=lab user=postgres', replication_sets := ARRAY['default'], synchronize_structure := false, synchronize_data := true, forward_origins := '{}'); SELECT spock.sub_wait_for_sync('from_a'); SELECT * FROM public.accounts WHERE id = 1; -- A SELECT spock.sub_create('from_b', 'host=127.0.0.1 port=5542 dbname=lab user=postgres', replication_sets := ARRAY['default'], synchronize_structure := false, synchronize_data := false, forward_origins := '{}'); SELECT spock.sub_wait_for_sync('from_b'); ``` ## Check both writers {#write} ```sql -- A INSERT INTO public.accounts VALUES (2, 'from_a', 50); -- B SELECT * FROM public.accounts WHERE id = 2; -- B, after seeing (2, from_a, 50) UPDATE public.accounts SET label = 'from_b', balance = balance + 2 WHERE id = 2; -- A SELECT * FROM public.accounts WHERE id = 2; ``` On each read, poll until the row arrives before moving to the next step. A should finally return `(2,from_b,52)`. Check `SELECT subscription_name, status FROM spock.sub_show_status()` on both nodes. Both should say `replicating`. A local COMMIT may return before the peer sees the row. [Operate the pair](/docs/spock/operations/) --- Backlinks: - [pgEdge](/docs/spock/) - [Conflicts, monitoring and catch-up](/docs/spock/operations/) ================ Source: https://mimus.pgsty.com/docs/spock/operations/index.md ================ # Conflicts, monitoring and catch-up > Choose how concurrent writes converge and diagnose a stalled subscription. --- LLMS index: [llms.txt](/llms.txt) --- ## Design for concurrent writers {#conflicts} With `last_update_wins` and commit-timestamp tracking, a conflicting ordinary value follows the newer commit timestamp. Synchronize the node clocks. A later timestamp can discard a business change. Assign writers disjoint keys when possible and use a non-deferrable primary key for updates and deletes. Two independent sequences can allocate the same ID. Additional unique constraints can also reject an incoming row. The `balance` column in the [example](/docs/spock/two-nodes/) logs its previous value. Delta Apply combines the remote change with the current local balance. In the two-node test, both sides started at 100 and committed increments of 7 and 13 while disconnected from apply. Both finished at 120. Ordinary text columns retained the winning writer’s value. Choose this policy for additive quantities. Test domain constraints such as overdraft limits separately. [Spock conflict handling](https://github.com/pgEdge/spock/blob/v5.0.15/docs/conflicts.md) ## Observe each direction {#monitor} ```sql 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; SELECT count(*) FROM spock.exception_log; ``` A subscription reports its receiver state; the provider slot shows whether a consumer is attached and how much WAL is being retained. Compare successive LSNs while generating known writes. Use `spock.resolutions` (with `save_resolutions` on) to inspect resolved conflicts and the exception log and server log to investigate apply errors. Verify the row values on both databases. A subscriber in the integration test stopped, restarted and caught up from retained WAL. If progress stalls, check connectivity, receiver logs, slot validity, schema equality and available disk space. Preserve a needed slot while diagnosing it. An invalidated slot or missing WAL may require a new consistent copy of the data. Coordinate the authoritative copy and reconcile writes on both sides before reseeding. ## Schema changes {#ddl} This setup uses matching, manually created objects with automatic DDL replication off. Pause writes on both nodes, let subscriptions catch up and coordinate schema changes. Temporary and unlogged tables are outside the replication set. Evaluate dialect-specific DDL, sequence allocation and multi-subscription recovery in the application’s own rehearsal. [Spock limitations](https://github.com/pgEdge/spock/blob/v5.0.15/docs/limitations.md) The upstream 6.0 manual introduces `spock.node_report()` and `spock.event_history_size`. The 5.0.15 extension sources used by Mimus do not define either interface. Use `spock.sub_show_status()` and the replication-slot queries above on this build. [Upstream 6.0 monitoring changes](/docs/spock/upstream/spock/spock-release-notes/#node-monitoring) --- Backlinks: - [Conflicts & Failover](/docs/guides/failover-and-conflicts/) - [pgEdge](/docs/spock/) - [Start two writable nodes](/docs/spock/two-nodes/) ================ Source: https://mimus.pgsty.com/docs/spock/recovery/index.md ================ # Recovery, failover and rollback > Identify the WAL boundary for physical recovery and the scope of logical fallback. --- LLMS index: [llms.txt](/llms.txt) --- ## Before the first subscription {#prepare} Upgrade physical standbys, failover hosts and PITR environments first. A new standby was able to follow a pre-Spock primary. Verify replay and the matching backup tools and keys, then switch the primary. Take a restorable base backup and record a pre-activation recovery point. Archive continuously. A backup of one node preserves that database’s physical state at its recovery point. Writes committed only on a disconnected peer require a separate reconciliation. ## Restore and verify {#restore} Recover a separate, network-isolated copy using a kernel with the 200 / 201 changes. Keep subscriptions from reconnecting to live peers during the drill. With TDE, follow the [key and backup procedure](/docs/tde/recovery/). Restore through the target WAL, pause at the chosen target and check `pg_is_in_recovery()` and `pg_get_wal_replay_pause_state()`. Compare representative rows, `xmin` and `pg_xact_commit_timestamp(xmin)` against values recorded at the target. Verify the table and index encryption status, and the absence of a transaction committed after the target. The test restored ordinary and encrypted tables to a named point after Delta Apply, with both plaintext and encrypted WAL on the full kernel. Before promoting a physical standby to serve both writers, verify slots, origins, subscriptions and convergence with the other node. On Debian 13 amd64, r4 passed all seven Spock checks. After standby catch-up and promotion, row values, commit timestamps and origins matched the primary. The concurrent test verified two subscription apply workers. ## How far can an older reader go? {#rollback} | Situation | Operational decision | | --- | --- | | Before Spock activation | A prior same-major reader handled ordinary WAL in the tested combination. Preserve a pre-activation backup and target for a rollback drill. | | Replay crosses `CommitTs/SUBTRANS_TS` | Keep the matching RC2 recovery environment for archives with the old `0x20` record. At cutover, quiesce writes and subscriptions and shut down cleanly. Equip the primary and recovery hosts with r4, take a new full backup and rebuild physical standbys from it before resuming replication. | | Return to an older system and keep later writes | Recover first with the matching kernel. Quiesce or reconcile writers, migrate representable application data logically and compare the rows. The fallback test moved one business table. Rebuild and validate roles, sequences, keys and topology separately. | In the earlier physical-reader test the old kernel reached a pre-conflict point with balance 113. The new kernel restored the same backup through the conflict and read 120. A marked directory also enforces its kernel requirements at startup. Keep the feature marker intact. Control-file version and a successful clean start alone cannot qualify a recovery reader. [How Spock changes replay](/docs/reference/patches/spock/) --- Backlinks: - [Conflicts & Failover](/docs/guides/failover-and-conflicts/) - [Verification Matrix](/docs/reference/verification/) - [pgEdge](/docs/spock/) - [Mimus 19.0.1 (r4 candidate)](/release/19.0.1/) ================ Source: https://mimus.pgsty.com/docs/spock/upstream/index.md ================ # pgEdge upstream manuals > Documentation for core pgEdge extensions. --- LLMS index: [llms.txt](/llms.txt) --- > [!NOTE] Upstream pgEdge reference collection > The upstream Spock manual covers 6.0.0-beta.2 and includes 5.0 maintenance notes. For deployment, configuration and recovery on Mimus, use [Spock 5.0.15](/docs/spock/). Four extensions address concrete tasks in distributed PostgreSQL. Start with Spock replication, then add identifiers, large-object replication, and session protection as your application needs them. - [Spock](/docs/spock/upstream/spock/) — Multi-master replication and conflicts - [Snowflake](/docs/spock/upstream/snowflake/) — Distributed unique IDs - [LOLOR](/docs/spock/upstream/lolor/) — Large object logical replication - [SafeSession](/docs/spock/upstream/safesession/) — Read-only sessions by role {.cards} The English source set is Spock v6.0.0-beta.2, LOLOR 1.3.0 development, SafeSession v1.1, and Snowflake v2.6.1. All 118 English pages have Chinese counterparts. See [sources and versions](/docs/spock/upstream/about/attribution/). ## Start reading {#start} - [Quick start](/docs/spock/upstream/quick-start/) - [Sources and versions](/docs/spock/upstream/about/attribution/) [PG.CENTER edition](https://github.com/pgsty/doc.pg.center/blob/4410c32dc9186a22859008303f474b72a779f583/content/pgedge/_index.md) · [Upstream source](https://github.com/pgEdge/spock/tree/d05e2e2b6a82796d86e3c16ffb0d3fc38b1b329c) --- Section pages: - [Quick start](/docs/spock/upstream/quick-start/): A reading path for a two-node Spock cluster. - [Spock](/docs/spock/upstream/spock/): The Spock extension provides multi-master (active-active) replication for pgEdge Distributed and Enterprise Postgres, versions 15, 16, 17, 18, and 19. - [LOLOR](/docs/spock/upstream/lolor/): lolor is an extension that makes Postgres-style large objects compatible with logical Replication. - [Snowflake](/docs/spock/upstream/snowflake/): Using a Snowflake sequence allows you to take full advantage of the benefits offered by a distributed, multi-master replication solution. - [SafeSession](/docs/spock/upstream/safesession/): pgEdge SafeSession is a PostgreSQL extension that enforces read-only sessions for specified database roles. - [About this site](/docs/spock/upstream/about/): Sources, licensing, versions, and maintenance. --- Backlinks: - [pgEdge](/docs/spock/) ================ Source: https://mimus.pgsty.com/docs/spock/upstream/quick-start/index.md ================ # Quick start > A reading path for a two-node Spock cluster. --- LLMS index: [llms.txt](/llms.txt) --- > The upstream Spock manual covers 6.0.0-beta.2 and includes 5.0 maintenance notes. For deployment, configuration and recovery on Mimus, use [Spock 5.0.15](/docs/spock/). Read the installation prerequisites, then follow the complete two-node procedure. Spock requires PostgreSQL server patches, compatible table definitions, and authenticated connections between nodes. ![Two PostgreSQL nodes accept reads and writes, with asynchronous bidirectional Spock replication.](/docs/spock/upstream/assets/images/replication-light.svg) {width="600" height="388" caption="Two-node replication. Commits complete locally; visibility on the other node depends on replication lag."} - [Installation prerequisites](/docs/spock/upstream/spock/installation/) - [End-to-end installation](/docs/spock/upstream/spock/getting-started/) - [Two-node procedure](/docs/spock/upstream/spock/two-node/) - [Resource sizing](/docs/spock/upstream/spock/sizing/) - [Conflict types](/docs/spock/upstream/spock/conflicts/) - [Limitations](/docs/spock/upstream/spock/limitations/) {.cards} [PG.CENTER edition](https://github.com/pgsty/doc.pg.center/blob/4410c32dc9186a22859008303f474b72a779f583/content/pgedge/quick-start/_index.md) · [Upstream source](https://github.com/pgEdge/spock/tree/4ac1aec2f0807dc7ee806ab99a6e99a4556186df) --- Backlinks: - [pgEdge Suite](/docs/spock/upstream/) ================ Source: https://mimus.pgsty.com/docs/spock/upstream/spock/index.md ================ # Spock > The Spock extension provides multi-master (active-active) replication for pgEdge Distributed and Enterprise Postgres, versions 15, 16, 17, 18, and 19. --- LLMS index: [llms.txt](/llms.txt) --- > The upstream Spock manual covers 6.0.0-beta.2 and includes 5.0 maintenance notes. For deployment, configuration and recovery on Mimus, use [Spock 5.0.15](/docs/spock/). > [!NOTE] Source version > The English source is **v6.0.0-beta.2 (pre-release)**, pinned at `d05e2e2b6a82`. A Chinese edition of this snapshot is available. Check [versions and sources](/docs/spock/upstream/about/attribution/) before deploying. The Spock extension provides multi-master (active-active) replication for pgEdge Distributed and Enterprise Postgres, versions 15, 16, 17, 18, and 19. The extension leverages the pgLogical open-source project as a solid foundation to build upon for this enterprise-class extension. > [!NOTE] Welcome to Spock: Live Long and Prosper! ## Continue reading {#continue-reading} - [Frequently Asked Questions](/docs/spock/upstream/spock/faq/) - [Configuring Spock](/docs/spock/upstream/spock/configuration/) - [Conflict Types](/docs/spock/upstream/spock/conflicts/) - [Conflict-Free Delta-Apply Columns (Conflict Avoidance)](/docs/spock/upstream/spock/conflict-avoidance/) - [Creating a Spock Cluster: End-to-End Installation Guide](/docs/spock/upstream/spock/getting-started/) - [Installing and Configuring the Spock Extension](/docs/spock/upstream/spock/installation/) - [Limitations and Restrictions](/docs/spock/upstream/spock/limitations/) - [Logical Slot Failover](/docs/spock/upstream/spock/logical-slot-failover/) - [pglogical to Spock function names](/docs/spock/upstream/spock/pgl-cheat-sheet/) - [Sizing Postgres Resources for Spock](/docs/spock/upstream/spock/sizing/) - [Spock Release Notes](/docs/spock/upstream/spock/spock-release-notes/) - [Troubleshooting Spock](/docs/spock/upstream/spock/troubleshooting/) - [Using Spock to Create a Two-Node Cluster](/docs/spock/upstream/spock/two-node/) - [Upgrading the Spock Extension](/docs/spock/upstream/spock/upgrading/) --- [Upstream source](https://github.com/pgEdge/spock/blob/d05e2e2b6a82796d86e3c16ffb0d3fc38b1b329c/docs/index.md) · `d05e2e2b6a82` · Copyright (c) 2021–2026, pgEdge, Inc.; portions Copyright the PostgreSQL Global Development Group and The Regents of the University of California. [PostgreSQL License](/docs/spock/upstream/about/license/). [PG.CENTER edition](https://github.com/pgsty/doc.pg.center/blob/4410c32dc9186a22859008303f474b72a779f583/content/pgedge/spock/_index.md) --- Section pages: - [Installing and Configuring the Spock Extension](/docs/spock/upstream/spock/installation/): The Spock extension can be installed with pgEdge Postgres packages or built from source. pgEdge Postgres deployments provide a simplified upgrade path that allows you to take advantage of important new features quickly and easily. - [Creating a Spock Cluster: End-to-End Installation Guide](/docs/spock/upstream/spock/getting-started/): This guide walks you through installing Spock and creating a two-node active-active replication cluster. - [Using Spock to Create a Two-Node Cluster](/docs/spock/upstream/spock/two-node/): After installing and initializing Postgres and creating the Spock Extension, you can use the following steps to configure a two-node cluster. - [Sizing Postgres Resources for Spock](/docs/spock/upstream/spock/sizing/): Spock replication consumes three separate, independently-configured Postgres resources: background worker slots, walsender slots, and replication slots/origins. - [Configuring Spock](/docs/spock/upstream/spock/configuration/): Add the following postgresql.conf settings on each node in your Spock replication scenario before creating the Spock extension: - [Managing a Spock Installation](/docs/spock/upstream/spock/managing/): The Spock extension is a powerful addition to any PostgreSQL installation; management features of the Spock extension allow you to seamlessly: - [Adding a Node to a Replicating Cluster](/docs/spock/upstream/spock/modify/): There are several tools and scripts you can use to add a node to a cluster; the way that you choose should depend on the use and state of your cluster: - [Conflict Types](/docs/spock/upstream/spock/conflicts/): For conflict avoidance using delta-apply columns, see Conflict Avoidance and Delta-Apply Columns. - [Conflict-Free Delta-Apply Columns (Conflict Avoidance)](/docs/spock/upstream/spock/conflict-avoidance/): Conflicts can arise if a node is subscribed to multiple providers, or when local writes happen on a subscriber node. - [Monitoring the Configuration and Health of Your Cluster](/docs/spock/upstream/spock/monitoring/): The Spock extension provides several ways you can monitor data health in your Postgres cluster: - [Spock Functions](/docs/spock/upstream/spock/reference/): The following user functions are available via the Spock extension: - [Upgrading the Spock Extension](/docs/spock/upstream/spock/upgrading/): If you're upgrading a secure production environment, shut down each node sequentially and perform the following steps: - [Recovery](/docs/spock/upstream/spock/recovery/): Recovery: section index. - [Logical Slot Failover](/docs/spock/upstream/spock/logical-slot-failover/): Spock creates logical replication slots on each provider node. - [Limitations and Restrictions](/docs/spock/upstream/spock/limitations/): Spock has several limitations and restrictions that users should be aware of when designing and implementing replication scenarios. - [Internals](/docs/spock/upstream/spock/internals-doc/): Internals: section index. - [Troubleshooting Spock](/docs/spock/upstream/spock/troubleshooting/): This document provides solutions to common issues encountered when using Spock for PostgreSQL logical replication. - [Frequently Asked Questions](/docs/spock/upstream/spock/faq/): Column filters work fine on tables with OIDs, but spock cannot filter on system columns like oid or xmin. - [Spock Release Notes](/docs/spock/upstream/spock/spock-release-notes/): This section lists what changed since 6.0.0-beta.1, for those testing the beta. - [pglogical to Spock function names](/docs/spock/upstream/spock/pgl-cheat-sheet/): Spock's function names are shorter than pglogical's, so a cluster or a script being ported from pglogical 2 needs almost every call renamed. --- Backlinks: - [pgEdge](/docs/spock/) - [pgEdge Suite](/docs/spock/upstream/) ================ Source: https://mimus.pgsty.com/docs/spock/upstream/spock/installation/index.md ================ # Installing and Configuring the Spock Extension > The Spock extension can be installed with pgEdge Postgres packages or built from source. pgEdge Postgres deployments provide a simplified upgrade path that allows you to take advantage of important new features quickly and easily. --- LLMS index: [llms.txt](/llms.txt) --- > The upstream Spock manual covers 6.0.0-beta.2 and includes 5.0 maintenance notes. For deployment, configuration and recovery on Mimus, use [Spock 5.0.15](/docs/spock/). The Spock extension can be installed with pgEdge Postgres packages or built from source. pgEdge Postgres deployments provide a simplified upgrade path that allows you to take advantage of important new features quickly and easily. Spock is open-source, with code available for review at [GitHub](https://github.com/pgEdge). > [!WARNING] > > Spock uses files stored in the `spock` schema to provide replication > functionality. Do not delete, create, or modify files in the `spock` > schema directly; use Spock functions and procedures to manage > replication. > For detailed information about using Spock to create a two-node cluster, see [Creating a Two-Node Cluster](/docs/spock/upstream/spock/two-node/). ## Installing Spock with pgEdge Enterprise Postgres {#installing-spock-with-pgedge-enterprise-postgres} The latest Spock extension is automatically installed with any [pgEdge Enterprise Postgres](https://docs.pgedge.com/enterprise) installation. A pgEdge deployment provides quick and easy access to the following features: - the latest minor version of your preferred Postgres version. - Spock [functions and procedures](/docs/spock/upstream/spock/reference/). - [ACE consistency monitoring](https://docs.pgedge.com/platform/ace). - [Snowflake sequences](https://docs.pgedge.com/platform/snowflake). - [pgBackRest](https://docs.pgedge.com/platform/managing/pgbackrest) for simplified backup and restore capabilities. - [LOLOR](https://docs.pgedge.com/lolor/v1-2-2/) large object support. - management tools for your active-active distributed cluster. ## Building the Extension from Source {#building-the-extension-from-source} Spock is available as an [open-source project](https://github.com/pgEdge/spock) that you can build from source code distributed at the GitHub project page. The Spock extension must be built on a version-specific build of Postgres that is patched to provide hooks so `spock` can access the Postgres engine. To patch the Postgres source code, download the source code from the [Postgres project](https://www.postgresql.org/ftp/source/), and move into the source directory. Then, clone the `spock` directory: ```bash git clone https://github.com/pgEdge/spock.git ``` Then, apply the `.diff` files from the `spock/patches/version` directory that match your build version. To apply a patch, use the command: ```bash patch -p1 < path_to_patch/patch_name ``` After applying version-specific patches, you can configure, `make`, and `make install` the Postgres server as described in the [Postgres documentation](https://www.postgresql.org/docs/current/installation.html). When the build completes, add the location of your `pg_config` file to your `PATH` variable: ```bash export PATH=path_to_pg_config_file ``` Before invoking `make` and `make install`, install the [jansson library](https://jansson.readthedocs.io/en/1.1/gettingstarted.html) to meet Spock prerequisites. Then, move into the `spock` directory, and use a build process much like any other Postgres extension: ```bash make make install ``` ## Configuring Postgres for Spock Replication {#configuring-postgres-for-spock-replication} After installing Postgres on each node that will host a spock instance, use [initdb](https://www.postgresql.org/docs/18/app-initdb.html) to initialize a Postgres cluster. After initializing the cluster, you can connect with psql, and query the server for file locations and cluster details: ```sql [sdouglas@lima-pg3 pg18]$ sudo -u postgres psql -U postgres -p 5432 psql (18.1) Type "help" for help. postgres=# SHOW data_directory; SHOW config_file; SHOW hba_file; data_directory ------------------------ /var/lib/pgsql/18/data (1 row) config_file ---------------------------------------- /var/lib/pgsql/18/data/postgresql.conf (1 row) hba_file ------------------------------------ /var/lib/pgsql/18/data/pg_hba.conf (1 row) ``` Then, use your choice of editor to update the `postgresql.conf` file, adding required Postgres parameters to the end of the file: ```sql wal_level = logical max_worker_processes = 20 # see the sizing guide below max_replication_slots = 10 max_wal_senders = 10 shared_preload_libraries = 'spock' track_commit_timestamp = on output_plugin_libraries = 'pgoutput, test_decoding, spock_output' # only on servers that have this parameter; see below ``` The values above are a working starting point for a small cluster (two or three nodes, one replicated database). They are not one-size-fits-all: Spock launches a supervisor, a slot sync worker, one background worker per database in the instance, and one per subscription; subscription counts scale with node count multiplied by the number of replicated databases, and `max_worker_processes` is shared with parallel query workers. See [Sizing Postgres Resources for Spock](/docs/spock/upstream/spock/sizing/) for the formulas and per-cluster recommendations before going to production. Set `output_plugin_libraries` only if your server has that parameter — it was added by a 2026 security fix and, without `spock_output` listed there, logical decoding fails with `library "spock_output" may not be used as an output plugin`. The check runs every time decoding starts, so it stops established clusters after a minor-version upgrade too, and it applies to every node. On older releases the parameter does not exist and setting it stops the server from starting. See [Configuring Spock](/docs/spock/upstream/spock/configuration/) for how to check. Note on replication origin states: - PostgreSQL 15-17: The `max_replication_slots` parameter controls both the number of replication slots and the number of replication origin states; when sizing this parameter, account for both slots and origins (one origin per subscription, and subscriptions are counted per replicated database). - PostgreSQL 18+: A new parameter `max_active_replication_origins` was introduced to separately control the number of replication origin states; the default value is 10, which may be insufficient for clusters with many subscriptions; set this to at least the number of subscriptions this node applies - `(nodes - 1) x replicated databases` in a full mesh - plus some headroom (similar sizing to `max_replication_slots`). After modifying the Postgres parameters, use your OS-specific command to restart the Postgres server: ```bash [sdouglas@lima-pg3 pg18]$ sudo systemctl restart postgresql-18 [sdouglas@lima-pg3 pg18]$ sudo systemctl status postgresql-18 ● postgresql-18.service - PostgreSQL 18 database server Loaded: loaded (/usr/lib/systemd/system/postgresql-18.service; enabled; preset: disabled) Active: active (running) since Wed 2026-02-11 11:44:11 EST; 7s ago ``` Then, connect to the psql command line, and create the spock extension: ```sql postgres=# CREATE EXTENSION spock; CREATE EXTENSION postgres=# ``` On each node that will host spock, modify the [`pg_hba.conf` file](https://www.postgresql.org/docs/current/auth-pg-hba-conf.html) and allow connections between `n1` and `n2`. The following snippet is provided as an example only, and is not recommended for a production system as it will open your system for connection from any client: ```sql host all all /32 trust host all all /32 trust host replication all /32 trust host replication all /32 trust ``` ### Creating a Replication Scenario {#creating-a-replication-scenario} After configuring the nodes, connect to the psql command line of the first provider node, and use the `spock.node_create` command to create the provider node: ```sql SELECT spock.node_create( node_name := 'provider1', dsn := 'host=providerhost port=5432 dbname=db' ); ``` Then, add the tables in the `public` schema to the `default` replication set: ```sql SELECT spock.repset_add_all_tables('default', ARRAY['public']); ``` Once the provider node is configured, you can add subscribers. First, create the subscriber node: ```sql SELECT spock.node_create( node_name := 'subscriber1', dsn := 'host=thishost port=5432 dbname=db' ); ``` Then, create the subscription which will start synchronization and replication on the subscriber node: ```sql SELECT spock.sub_create( subscription_name := 'subscription1', provider_dsn := 'host=providerhost port=5432 dbname=db' ); SELECT spock.sub_wait_for_sync('subscription1'); ``` --- [Upstream source](https://github.com/pgEdge/spock/blob/d05e2e2b6a82796d86e3c16ffb0d3fc38b1b329c/docs/install_spock.md) · `d05e2e2b6a82` · Copyright (c) 2021–2026, pgEdge, Inc.; portions Copyright the PostgreSQL Global Development Group and The Regents of the University of California. [PostgreSQL License](/docs/spock/upstream/about/license/). [PG.CENTER edition](https://github.com/pgsty/doc.pg.center/blob/4410c32dc9186a22859008303f474b72a779f583/content/pgedge/spock/installation.md) --- Backlinks: - [Quick start](/docs/spock/upstream/quick-start/) - [Spock](/docs/spock/upstream/spock/) - [Slot failover](/docs/spock/upstream/spock/logical-slot-failover/) ================ Source: https://mimus.pgsty.com/docs/spock/upstream/spock/getting-started/index.md ================ # Creating a Spock Cluster: End-to-End Installation Guide > This guide walks you through installing Spock and creating a two-node active-active replication cluster. --- LLMS index: [llms.txt](/llms.txt) --- > The upstream Spock manual covers 6.0.0-beta.2 and includes 5.0 maintenance notes. For deployment, configuration and recovery on Mimus, use [Spock 5.0.15](/docs/spock/). This guide walks you through installing Spock and creating a two-node active-active replication cluster. Before you begin, ensure you have met the following prerequisites: - Each node must be a physical or virtual machine with network connectivity. - You must have administrative access to both nodes. - A basic familiarity with PostgreSQL and command-line operations is required. The installation process follows these steps. 1. Add the pgEdge repository and install pgEdge Postgres with Spock. 2. Configure PostgreSQL parameters for logical replication. 3. Create the Spock extension on both nodes. 4. Set up node definitions and bidirectional subscriptions. 5. Enable automatic DDL replication across the cluster. 6. Test the cluster to verify bidirectional replication works correctly. ## Install pgEdge Enterprise Postgres (Recommended Path) {#install-pgedge-enterprise-postgres-recommended-path} This section describes how to install pgEdge Enterprise Postgres with Spock using the pgEdge repository. First, on each node, add the pgEdge repository to your system. For RHEL/Rocky Linux/AlmaLinux 10, first install EPEL: ```bash sudo dnf -y install https://dl.fedoraproject.org/pub/epel/epel-release-latest-10.noarch.rpm ``` On RHEL 10, also enable the CodeReady Builder repository: ```bash sudo subscription-manager repos --enable codeready-builder-for-rhel-10-$(arch)-rpms ``` On Rocky Linux 10 or AlmaLinux 10, enable the equivalent CRB repository instead: ```bash sudo dnf config-manager --set-enabled crb ``` Version-specific commands for RHEL, OEL, Alma, and Rocky are available in the [pgEdge Enterprise Postgres documentation](https://docs.pgedge.com/enterprise/el/configure-repo/). For Ubuntu/Debian: Before configuring local access to the pgedge repository, you should ensure that your system does not contain any community Postgres packages. Then, install the platform-specific prerequisites for your system with the commands: ```bash sudo apt-get update sudo apt-get install -y curl sudo apt-get install -y gnupg2 sudo apt-get install -y lsb-release ``` Then, create the repository with the commands: ```bash sudo curl -sSL https://apt.pgedge.com/repodeb/pgedge-release_latest_all.deb -o /tmp/pgedge-release.deb sudo dpkg -i /tmp/pgedge-release.deb sudo rm -f /tmp/pgedge-release.deb sudo apt update ``` > [!NOTE] > > For detailed information about using the pgEdge repository, see the > [pgEdge Enterprise Postgres documentation](https://docs.pgedge.com/enterprise/). > > After creating the repository, install your preferred PostgreSQL version. The examples use PostgreSQL 18. If you switch to 15, 16, 17, or 19, update every versioned package, path, and service name in the snippets below. For RHEL/Rocky Linux/AlmaLinux: ```bash sudo dnf install -y pgedge-postgres18-server pgedge-postgres18-contrib pgedge-spock50_18 ``` For Ubuntu/Debian: ```bash sudo apt install -y pgedge-postgresql-18 pgedge-postgresql-18-spock50 ``` On each node, initialize the PostgreSQL database cluster. For RHEL/Rocky Linux/AlmaLinux: ```bash sudo /usr/pgsql-18/bin/postgresql-18-setup initdb sudo systemctl enable postgresql-18 sudo systemctl start postgresql-18 ``` For Ubuntu/Debian: ```bash sudo /usr/lib/postgresql/18/bin/initdb -D /var/lib/postgresql/18/data sudo systemctl enable postgresql-18 sudo systemctl start postgresql-18 ``` In the following example, the `psql` command connects to PostgreSQL to verify the installation: ```bash sudo -u postgres psql -U postgres -p 5432 ``` Once connected, confirm that you can see the configuration file locations. In the following example, the `SHOW` commands display the PostgreSQL configuration file locations: ```sql postgres=# SHOW data_directory; data_directory ------------------------ /var/lib/pgsql/18/data (1 row) postgres=# SHOW config_file; config_file ---------------------------------------- /var/lib/pgsql/18/data/postgresql.conf (1 row) postgres=# SHOW hba_file; hba_file ------------------------------------ /var/lib/pgsql/18/data/pg_hba.conf (1 row) ``` The pgEdge Enterprise Postgres installation automatically includes the following components: - The latest minor version of your chosen Postgres version. - The Spock extension (pre-installed, ready to enable). - Spock functions and procedures. - ACE consistency monitoring. - Snowflake sequences. - pgBackRest for simplified backup and restore. - LOLOR large object support. - Management tools for active-active distributed clusters. ## Install from Source (Alternative Path) {#install-from-source-alternative-path} If you need to build Spock from source instead of using pgEdge Enterprise Postgres, follow these steps. 1. Download PostgreSQL source code from the [Postgres project](https://www.postgresql.org/ftp/source/) and navigate to the source directory. 2. Clone the Spock repository with the following command: ```bash git clone https://github.com/pgEdge/spock.git ``` 3. Apply the version-specific patches with the following command: ```bash patch -p1 < spock/patches/version/patch_name ``` 4. Configure, build, and install PostgreSQL as described in the [Postgres documentation](https://www.postgresql.org/docs/current/installation.html). 5. Add the `pg_config` file location to your PATH with this command: ```bash export PATH=path_to_pg_config_file ``` 6. Install the [jansson library](https://jansson.readthedocs.io/en/1.1/gettingstarted.html) (required for Spock). 7. Build and install Spock with the following commands: ```bash cd spock make make install ``` Repeat the installation process on both nodes. After building from source, use [initdb](https://www.postgresql.org/docs/18/app-initdb.html) to initialize a PostgreSQL cluster on each node. ## Configure PostgreSQL for Spock Replication {#configure-postgresql-for-spock-replication} On each node, edit the `postgresql.conf` file and add the required parameters to the end of the file. In the following example, the configuration parameters enable logical replication and load the Spock extension: ```sql wal_level = logical max_worker_processes = 20 # see the sizing guide max_replication_slots = 10 # two per subscriber, per replicated database, # plus one per physical standby; 10 covers a # four-node mesh replicating one database max_wal_senders = 10 # keep equal to max_replication_slots shared_preload_libraries = 'spock' track_commit_timestamp = on # needed for conflict resolution listen_addresses = '*' output_plugin_libraries = 'pgoutput, test_decoding, spock_output' # only on servers that have this parameter; see below ``` > [!NOTE] Sizing `max_worker_processes` > > This parameter covers more than one worker per node: Spock runs a > supervisor, a slot sync worker (present on every node, primary or > standby), a manager for *every* connectable database in the instance > (including `postgres` and `template1`), an apply worker per subscription, > and a sync worker per subscription during table synchronization. > Subscriptions are created per database, so their count is the number of > other nodes *multiplied by* the number of replicated databases. The pool > is also shared with parallel query workers. See > [Sizing Postgres Resources for Spock](/docs/spock/upstream/spock/sizing/) for the formulas. > > [!NOTE] > > Set `output_plugin_libraries` only if your server has that parameter — it > was added by a 2026 security fix and, without `spock_output` listed there, > logical decoding fails with `library "spock_output" may not be used as an > output plugin`. The check runs every time decoding starts, so it stops > established clusters after a minor-version upgrade too, and it applies to > every node. On older releases the parameter does not exist and setting it > stops the server from starting. See > [Configuring Spock](/docs/spock/upstream/spock/configuration/) for how to check. > > [!NOTE] > > - PostgreSQL 15-17: The `max_replication_slots` parameter controls > both slots and replication origin states. Account for both when > sizing (one origin per subscription, and subscriptions are counted > per replicated database). > > - PostgreSQL 18+: A new parameter `max_active_replication_origins` > separately controls origin states. The default value is 10, which > may be insufficient. Set the value to at least the number of > subscriptions this node applies - `(nodes - 1) x replicated > databases` in a full mesh - plus headroom. > After modifying `postgresql.conf`, restart PostgreSQL using your OS-specific command. In the following example, the `systemctl` commands restart and verify the PostgreSQL service: ```bash sudo systemctl restart postgresql-18 sudo systemctl status postgresql-18 ``` Verify the service is active and running. On each node, modify the [`pg_hba.conf`](https://www.postgresql.org/docs/18/auth-pg-hba-conf.html) file to allow connections between the nodes. Add entries for both regular and replication connections. Replace `` and `` with your actual IP addresses. In the following example, the configuration entries allow connections from both nodes: ```conf # Regular connections host all all /32 trust host all all /32 trust host all all /24 trust # Replication connections host replication all /32 trust host replication all /32 trust ``` > [!WARNING] > > The example above uses `trust` authentication for simplicity and is > not recommended for production systems. In production, use > appropriate authentication methods like `scram-sha-256` or `md5`. > After modifying `pg_hba.conf`, reload the server configuration to apply the changes (no restart required): ```sql SELECT pg_reload_conf(); ``` ## Create the Spock Extension {#create-the-spock-extension} On each node, connect to PostgreSQL and create the Spock extension. In the following example, the `CREATE EXTENSION` command creates the Spock extension: ```sql sudo -u postgres psql -U postgres -p 5432 postgres=# CREATE EXTENSION spock; CREATE EXTENSION postgres=# ``` > [!WARNING] > > Spock uses the `spock` schema to provide replication functionality. > Do not delete, create, or modify files in the `spock` schema > directly. Use Spock functions and procedures to manage replication. > ## Create Nodes and Configure Replication {#create-nodes-and-configure-replication} This section describes how to set up bidirectional replication between the two nodes. For this guide, the nodes are named `n1` and `n2`. ### On Node 1 (n1) {#on-node-1-n1} Follow these steps to create the node definition and add tables to the replication set. 1. Create the node definition with the following command: ```sql SELECT spock.node_create( node_name := 'n1', dsn := 'host= port= dbname=' ); ``` 2. Add tables to the default replication set with this command: ```sql SELECT spock.repset_add_all_tables('default', ARRAY['public']); ``` If you are working in a schema other than `public`, adjust the schema name accordingly. ### On Node 2 (n2) {#on-node-2-n2} Follow these steps to create the node definition, add tables, and create the subscription. 1. Create the node definition with the following command: ```sql SELECT spock.node_create( node_name := 'n2', dsn := 'host= port= dbname=' ); ``` 2. Add tables to the default replication set with this command: ```sql SELECT spock.repset_add_all_tables('default', ARRAY['public']); ``` 3. Create the subscription from n2 to n1 with these commands: ```sql SELECT spock.sub_create( subscription_name := 'sub_n2_n1', provider_dsn := 'host= port= dbname=' ); SELECT spock.sub_wait_for_sync('sub_n2_n1'); ``` ### On Node 1 (n1) {#on-node-1-n1-1} Create the reverse subscription from n1 to n2 with the following commands: ```sql SELECT spock.sub_create( subscription_name := 'sub_n1_n2', provider_dsn := 'host= port= dbname=' ); SELECT spock.sub_wait_for_sync('sub_n1_n2'); ``` ### On Both Nodes (n1 and n2) {#on-both-nodes-n1-and-n2} To ensure DDL statements are automatically replicated across your cluster, run these commands on both nodes. In the following example, the `ALTER SYSTEM` commands enable automatic DDL replication: ```sql ALTER SYSTEM SET spock.enable_ddl_replication = on; ALTER SYSTEM SET spock.include_ddl_repset = on; SELECT pg_reload_conf(); ``` These settings enable the following features: - DDL statements are automatically replicated through the default replication set. - New tables are automatically added to replication sets; tables with primary keys are added to the default set, and tables without primary keys are added to the default_insert_only set. ## Verify the Cluster {#verify-the-cluster} On each node, use the following command to verify that nodes are properly configured. In the following example, the `SELECT` command displays the configured nodes: ```sql SELECT * FROM spock.node; ``` Expected output: ```sql postgres=# SELECT * FROM spock.node; -[ RECORD 1 ]---- node_id | 26863 node_name | n2 location | country | info | -[ RECORD 2 ]---- node_id | 49708 node_name | n1 location | country | info | ``` Then, use the following command to verify that subscriptions are active and replicating. In the following example, the `SELECT` command displays the subscription status: ```sql SELECT * FROM spock.sub_show_status(); ``` Expected output: ```sql postgres=# SELECT * FROM spock.sub_show_status(); -[ RECORD 1 ]-----+-------------------------------------------------------------------- subscription_name | sub_n1 status | replicating provider_node | n2 provider_dsn | host=192.168.105.11 dbname=postgres user=postgres password=password slot_name | spk_postgres_n2_sub_n1 replication_sets | {default,default_insert_only,ddl_sql} forward_origins | ``` The `status` field should display `replicating`. ## Test Replication {#test-replication} Perform a simple replication test using the following steps. 1. On n1, create a test table with the following commands: ```sql CREATE TABLE test ( id SERIAL PRIMARY KEY, message TEXT ); INSERT INTO test (message) VALUES ('Hello from n1'); ``` 2. On n2, verify the table exists and contains the data with this query: ```sql SELECT * FROM test; ``` Expected output: ```sql postgres=# SELECT * FROM test; -[ RECORD 1 ]------ id | 1 message | Hello from n1 ``` 3. On n2, insert a new row with the following command: ```sql INSERT INTO test (message) VALUES ('Hello from n2'); ``` 4. On n1, verify both rows are present with this query: ```sql SELECT * FROM test; ``` Expected output: ```sql postgres=# SELECT * FROM test; -[ RECORD 1 ]------ id | 1 message | Hello from n1 -[ RECORD 2 ]------ id | 2 message | Hello from n2 ``` Both messages should appear on both nodes, confirming that bidirectional replication is working. ## Next Steps {#next-steps} Your two-node Spock cluster is now operational. The following documents describe the next steps for configuring and managing the cluster. - The [Configuring Spock](/docs/spock/upstream/spock/configuration/) document describes conflict resolution settings and advanced configuration options. - The [Spock Functions Reference](/docs/spock/upstream/spock/reference/) document provides detailed information about monitoring functions and replication management. - The [Managing DDL Replication](/docs/spock/upstream/spock/managing/spock-autoddl/) document explains how to control automatic DDL replication behavior. ## Troubleshooting {#troubleshooting} If you encounter issues, review the following common problems and solutions. - Check the `pg_hba.conf` entries and ensure the nodes can connect to each other if replication is not starting. - Verify that `max_replication_slots` and `max_wal_senders` are set to sufficient values when a subscription is stuck initializing. A subscription that is synchronizing needs a second slot and walsender on the provider in addition to those held by its apply stream; see [Sizing Postgres Resources for Spock](/docs/spock/upstream/spock/sizing/). - If DDL is not replicating, confirm that the automatic DDL replication settings are enabled on both nodes. - If errors are not clear, review the PostgreSQL logs for detailed error messages. For more information, see the following resources: - The [Spock Functions Reference](/docs/spock/upstream/spock/reference/) document provides detailed function documentation. - The [Advanced Configuration Options](/docs/spock/upstream/spock/configuration/) document describes additional configuration parameters. - The [Managing DDL Replication](/docs/spock/upstream/spock/managing/spock-autoddl/) document explains DDL replication features. --- [Upstream source](https://github.com/pgEdge/spock/blob/d05e2e2b6a82796d86e3c16ffb0d3fc38b1b329c/docs/getting_started.md) · `d05e2e2b6a82` · Copyright (c) 2021–2026, pgEdge, Inc.; portions Copyright the PostgreSQL Global Development Group and The Regents of the University of California. [PostgreSQL License](/docs/spock/upstream/about/license/). [PG.CENTER edition](https://github.com/pgsty/doc.pg.center/blob/4410c32dc9186a22859008303f474b72a779f583/content/pgedge/spock/getting-started.md) --- Backlinks: - [Quick start](/docs/spock/upstream/quick-start/) - [Spock](/docs/spock/upstream/spock/) - [Tutorial: Upgrading the Postgres Version In Place with pg_upgrade](/docs/spock/upstream/spock/modify/pg-upgrade-rolling-tutorial/) - [Tutorial: Updating the Postgres Version with a Rolling Update](/docs/spock/upstream/spock/modify/zodan/zodan-rolling-pg-version-tutorial/) ================ Source: https://mimus.pgsty.com/docs/spock/upstream/spock/two-node/index.md ================ # Using Spock to Create a Two-Node Cluster > After installing and initializing Postgres and creating the Spock Extension, you can use the following steps to configure a two-node cluster. --- LLMS index: [llms.txt](/llms.txt) --- > The upstream Spock manual covers 6.0.0-beta.2 and includes 5.0 maintenance notes. For deployment, configuration and recovery on Mimus, use [Spock 5.0.15](/docs/spock/). > [!NOTE] Editorial note > The upstream example in step 3 gives `postgresql.conf` as the path to `pg_hba.conf`. Authentication rules belong in the actual `pg_hba.conf`; `SHOW hba_file;` reports its path. See [known upstream issues](/docs/spock/upstream/about/maintenance/#upstream-issues). After installing and initializing Postgres and creating the Spock Extension, you can use the following steps to configure a two-node cluster. In the examples that follow, we'll be creating a cluster that contains two nodes, named `n1` and `n2` that listen for Postgres server connections on port `5432`. 1. Connect to each node, and use the following commands to initialize a cluster: `sudo /usr/pgsql-17/bin/postgresql-17-setup initdb` `sudo systemctl enable postgresql-17` 2. Use your choice of editor to open the `postgresql.conf` file (located in `/var/lib/pgsql/17/data/postgresql.conf`) and add the following parameters to the bottom of the file: `wal_level = 'logical'` `max_worker_processes = 20` `max_replication_slots = 10` `max_wal_senders = 10` `shared_preload_libraries = 'spock'` `track_commit_timestamp = on` These values are sized for this two-node example, which replicates a single database. Before moving to production, or if you add nodes or databases, size them from your topology using [Sizing Postgres Resources for Spock](/docs/spock/upstream/spock/sizing/) - subscriptions are created per database, so slots, walsenders, and workers scale with node count multiplied by replicated database count, and `max_worker_processes` is additionally shared with parallel query workers and needs one slot per database in the instance, one for the supervisor, and one more for the slot sync worker. 3. Edit the [`pg_hba.conf` file](https://www.postgresql.org/docs/current/auth-pg-hba-conf.html) (use `SHOW hba_file;` to find its path) and allow connections between `n1` and `n2`; the following commands are provided as an example only, and are not recommended for production systems as they will open your system for connection from any client: `host all all 0.0.0.0/0 trust` `local replication all trust` `host replication all 0.0.0.0/0 trust` 4. Use the [`spock.node_create`](/docs/spock/upstream/spock/reference/functions/spock-node-create/) command to create the provider and subscriber nodes; on `n1`, use the command: `SELECT spock.node_create (node_name := 'n1', dsn := 'host= port= dbname=');` On `n2`: `SELECT spock.node_create (node_name := 'n2', dsn := 'host= port= dbname=');` 5. On `n1`, use the [`spock.repset_add_all_tables`](/docs/spock/upstream/spock/reference/functions/spock-repset-add-all-tables/) command to add the tables in the `public` schema to the `default` replication set. If you are working in another schema, customize this command as needed: `SELECT spock.repset_add_all_tables('default', ARRAY['public']);` 6. On n2, use the [`spock.sub_create`](/docs/spock/upstream/spock/reference/functions/spock-sub-create/) command to create the subscription between n2 and n1; the name of the subscription is `sub_n2_n1`: `SELECT spock.sub_create (subscription_name := 'sub_n2_n1', provider_dsn := 'host= port= dbname=');` `SELECT spock.sub_wait_for_sync('sub_n2_n1');` 7. On `n1`, create a corresponding subscription to `n2` named `sub_n1_n2`: `SELECT spock.sub_create (subscription_name := 'sub_n1_n2', provider_dsn := 'host= port= dbname=');` 8. To ensure that modifications to your [DDL statements are automatically replicated](/docs/spock/upstream/spock/managing/spock-autoddl/), connect to each node with a Postgres client and invoke the following SQL commands: `ALTER SYSTEM SET spock.enable_ddl_replication=on;` `ALTER SYSTEM SET spock.include_ddl_repset=on;` `ALTER SYSTEM SET spock.allow_ddl_from_functions=on;` `SELECT pg_reload_conf();` 9. Then, check the status of each node: ```sql SELECT * FROM spock.node; node_id | node_name | location | country | info ---------+-------------+----------+---------+------ 22201 | subscriber1 | | | 53107 | provider1 | | | (2 rows) SELECT * FROM spock.sub_show_status(); subscription_name | status | provider_node | provider_dsn | slot_name | replication_sets | forward_origins -------------------+-------------+---------------+------------------------------------------+--------------------------------------+---------------------------------------+----------------- subscription1 | replicating | provider1 | host=localhost port=5432 dbname=postgres | spk_postgres_provider1_subscription1 | {default,default_insert_only,ddl_sql} | (1 row) ``` A simple test to check that your system is replicating is to connect to the Postgres server on `n1` and add an object (like a table), and then confirm that it is available on `n2`. Similarly, you can create an object on `n2`, and confirm that it has been created on `n1`. --- [Upstream source](https://github.com/pgEdge/spock/blob/d05e2e2b6a82796d86e3c16ffb0d3fc38b1b329c/docs/two_node_cluster.md) · `d05e2e2b6a82` · Copyright (c) 2021–2026, pgEdge, Inc.; portions Copyright the PostgreSQL Global Development Group and The Regents of the University of California. [PostgreSQL License](/docs/spock/upstream/about/license/). [PG.CENTER edition](https://github.com/pgsty/doc.pg.center/blob/4410c32dc9186a22859008303f474b72a779f583/content/pgedge/spock/two-node.md) --- Backlinks: - [Maintenance and coverage](/docs/spock/upstream/about/maintenance/) - [Quick start](/docs/spock/upstream/quick-start/) - [Spock](/docs/spock/upstream/spock/) - [Installation](/docs/spock/upstream/spock/installation/) ================ Source: https://mimus.pgsty.com/docs/spock/upstream/spock/sizing/index.md ================ # Sizing Postgres Resources for Spock > Spock replication consumes three separate, independently-configured Postgres resources: background worker slots, walsender slots, and replication slots/origins. --- LLMS index: [llms.txt](/llms.txt) --- > The upstream Spock manual covers 6.0.0-beta.2 and includes 5.0 maintenance notes. For deployment, configuration and recovery on Mimus, use [Spock 5.0.15](/docs/spock/). Spock replication consumes three separate, independently-configured Postgres resources: background worker slots, walsender slots, and replication slots/origins. Each is governed by a different parameter, and each is sized from a different property of your cluster. Many of the values shown in the tutorials are a starting point for a small test cluster, not a recommendation for production. This page explains what Spock actually launches so you can size each parameter deliberately. > [!WARNING] > > Every parameter on this page backed by an explicit recommendation requires > a **server restart** to change. Under-sizing them is not a soft failure: > Spock raises an `ERROR` when a worker cannot be registered and the > supervisor retries in a loop, so replication does not start at all. Formulas > include a small amount of headroom partially to prevent this. > ## What Spock Runs on Each Node {#what-spock-runs-on-each-node} | Process | How many | Counts against | |---|---|---| | Supervisor | 1 per instance, always running | `max_worker_processes` | | Slot sync worker | 1 per instance | `max_worker_processes` | | Manager | 1 per **connectable database** in the instance | `max_worker_processes` | | Apply worker | 1 per enabled subscription | `max_worker_processes` | | Table sync worker | at most 1 concurrently per subscription | `max_worker_processes` | | Walsender | 1 per subscription streaming from this node, plus 1 more per subscription during table sync | `max_wal_senders` | {.wide .expand} Four of these counts are commonly misjudged. **A slot sync worker exists on every node, not just standbys.** These workers copy logical replication slots to each physical standby so that failovers do not force a full resync of every subscriber. These workers remain idle on primary nodes but still consume a worker slot, so are included in the formula. See [Slot Synchronization](#slot-synchronization) below for more information. **Managers are launched for every connectable database, not just the ones using Spock.** The supervisor cannot determine whether a database contains a Spock node without connecting to it, and a background worker cannot switch databases. So it launches a manager for every database in `pg_database` with `datallowconn = true`; managers that find no Spock node exit immediately. On a default cluster that means `postgres` and `template1` each get a short-lived manager in addition to your replicated database. `template0` is excluded because it does not allow connections. **Walsenders are not background workers.** They are governed by `max_wal_senders` and counted separately in `MaxBackends`. Raising `max_worker_processes` does nothing for walsender exhaustion, and vice versa. **Subscriptions are per database, not per node.** A Spock node is created inside a single database, and each subscription connects one database on this instance to the corresponding database on one other instance. An instance that replicates several databases therefore hosts one Spock node per replicated database, and each of those nodes carries its own full set of subscriptions. Everything downstream of the subscription count such as apply workers, table sync workers, walsenders, slots, and origins, all scale with **node count multiplied by replicated database count**, not node count alone. ### Slot Synchronization {#slot-synchronization} Slot synchronization is not optional for a cluster with a physical standby: a promotion without it forces every subscriber to recreate its slot and re-sync its tables. What changes between PostgreSQL versions is only *who supplies the worker*. | PostgreSQL | Supplied by | Charged to `max_worker_processes` | |---|---|---| | 15, 16 | Spock's `spock_failover_slots` background worker | Yes | | 17 | Either, depending on `sync_replication_slots` | Yes - Spock registers its worker regardless, and it stands down when the native one is enabled | | 18+ | PostgreSQL's native slotsync worker | No - it is a dedicated postmaster process, counted separately in `MaxBackends` | {.wide .expand} Budget a worker for it on every node and every version. Where PostgreSQL supplies the worker the budgeted slot simply becomes headroom, which costs nothing beyond a little shared memory and spares you a version-dependent formula. [Logical Slot Failover](/docs/spock/upstream/spock/logical-slot-failover/) covers the configuration each mechanism needs. ## Sizing `max_worker_processes` {#sizing-max_worker_processes} For one node, at peak: spock_workers = 1 # supervisor + 1 # slot sync worker + D # connectable databases in this instance + S # apply workers: one per enabled subscription + S # table sync workers: worst case, one per subscription max_worker_processes = spock_workers + max_parallel_workers # shared pool - see below + other_extension_workers # pg_cron, pg_squeeze, ... + 2 # headroom Where: - `N` is the number of Spock nodes in the cluster. - `D` is the number of databases in the instance with `datallowconn = true`, including `postgres` and `template1` — **not** just the databases participating in replication. - `R` is the number of databases in this instance that actually participate in Spock replication (`R <= D`). It is `1` in most deployments. - `S` is the total number of enabled subscriptions across all databases in the instance. In a fully-meshed cluster of `N` nodes each replicating the same `R` databases, `S = R * (N - 1)`. With a single replicated database that reduces to the familiar `S = N - 1`. > [!WARNING] > > `max_worker_processes` is a **shared pool**. Parallel query workers > (`max_parallel_workers`, default `8`), native logical replication workers > (`max_logical_replication_workers`), and background workers belonging to > other extensions all draw from the same allocation. A parallel-heavy > workload can starve replication of worker slots. Autovacuum workers are > the exception — they have their own `autovacuum_max_workers` allocation. > ### Recommended Minimums {#recommended-minimums} Assuming a single replicated database alongside `postgres` and `template1` (`D = 3`, `R = 1`), the default `max_parallel_workers = 8`, and no other worker-using extensions: | Cluster | Spock Workers | Total Workers | |---|---|---| | 2-node | 7 | 20 | | 3-node | 9 | 20 | | 4-node | 11 | 24 | | 5-node | 13 | 24 | | 8-node | 19 | 32 | {.wide .expand} The totals are rounded up to leave room for growth; there is no meaningful cost to over-provisioning `max_worker_processes` beyond a small amount of shared memory, and the parameter cannot be changed without a restart. Add to these numbers if your instance hosts more databases, replicates more than one database, or runs other extensions that register background workers. Each **additional replicated database** costs `1` manager (if the database is not already counted in `D`) plus `2 * (N - 1)` workers for its apply and sync workers, so a 3-node cluster replicating three databases needs `3 * 2 * 2 = 12` apply and sync workers per instance rather than `4`. ## Sizing `max_replication_slots` and `max_wal_senders` {#sizing-max_replication_slots-and-max_wal_senders} Each node holds a logical replication slot for every subscription that streams from it, plus a transient slot for each in-progress table sync. Sync slots are created as persistent slots (not temporary), so each one occupies a slot until the sync finishes and the slot is dropped. Every one of those slots has a walsender behind it while it is streaming, so **set both parameters to the same value** and compute it once, from the slot count. > [!NOTE] Default values > > The default is 10 for `max_replication_slots` and `max_wal_senders`. Consider > this a minimum value for each. If any formulas provide a value below 10, > simply retain the default value. > Where `N` is the number of Spock nodes and `R` the number of replicated databases in the instance: max_replication_slots = 2 * R * (N - 1) # apply slot + sync slot per subscription + physical_and_failover_slots + 2 # headroom for pg_basebackup and ad-hoc tooling max_wal_senders = max_replication_slots `R` is 1 in most deployments. A 5-node mesh replicating a single database, with one physical standby per node, needs `2 * 1 * 4 + 1 + 2 = 11` for both parameters; the same mesh replicating three databases needs `2 * 3 * 4 + 1 + 2 = 27`. > [!NOTE] Why the two values are equal > > PostgreSQL's logical replication documentation recommends setting > `max_wal_senders` to at least `max_replication_slots` plus the number of > physical replicas connected at the same time. That extra term covers > physical standbys that stream without a slot; the formula above already > gives each physical standby a slot in `physical_and_failover_slots`, so > adding them a second time would double-count. Sizing every node from the > same formula, standbys included, also satisfies the separate rule that a > standby's `max_wal_senders` be at least as high as its primary's. > Not every replication connection is a walsender. Table sync workers open a second, non-replication connection to run `COPY`, which draws from `max_connections`. The slot sync worker on a standby likewise reaches the primary over an ordinary connection. Both Spock's worker and PostgreSQL's native one cost the primary a `max_connections` slot, not a walsender. ## Replication Origins {#replication-origins} Postgres uses *origins* to track local state for remote replication slots. Internally, Postgres tracks replication origins separately from slots and pins their count to `max_replication_slots` in Postgres versions 15-17. Our formula should make it impossible for there to be more origins than slots in those versions of Postgres. However, Postgres 18 introduces `max_active_replication_origins` with a default value of 10, which may be too low for an active Spock cluster. For the sake of simplicity, we encourage using this simple formula for that parameter: max_active_replication_origins = max_replication_slots This should cause Postgres 18+ to operate with a sufficiently large origin pool. ## Worked Examples {#worked-examples} Because these settings require so many inputs, this documentation provides some examples. ### 3-Node Mesh {#3-node-mesh} Three nodes, each with a single replicated database `app`, plus the default `postgres` and `template1` databases. Each node subscribes to the other two, and each node has one physical standby. Per node: `D = 3`, `R = 1`, `S = R * (N - 1) = 2`. ```ini # Background workers: # 1 supervisor + 1 slot sync + 3 managers + 2 apply + 2 table sync = 9 # + 8 max_parallel_workers + 2 headroom = 19; 20 to match the table above max_worker_processes = 20 # Slots and walsenders, set equal: # (2 x 1 database x 2 subscribers) + 1 physical standby + 2 headroom = 7; # This is lower than the default of 10, so do not reduce. max_replication_slots = 10 max_wal_senders = 10 ``` ### 5-Node Mesh {#5-node-mesh} Five nodes, each with replicated databases `app` and `ledger`, plus the default `postgres` and `template1` databases. Each node subscribes to the other four, and each node has two physical standbys, common in clusters leveraging safe synchronous replication. Per node: `D = 4`, `R = 2`, `S = R * (N - 1) = 8`. ```ini # Background workers: # 1 supervisor + 1 slot sync + 4 managers + 8 apply + 8 table sync = 22 # + 8 max_parallel_workers + 2 headroom = 32 max_worker_processes = 32 # Slots and walsenders, set equal: # (2 x 2 databases x 4 subscribers) + 2 standbys + 2 headroom = 20 max_replication_slots = 20 max_wal_senders = 20 ``` ## Verifying Your Configuration {#verifying-your-configuration} List the Spock workers currently running on a node: ```sql SELECT pid, backend_type, datname FROM pg_stat_activity WHERE backend_type LIKE 'spock%' ORDER BY backend_type; ``` Each Spock worker reports its role and the OIDs it serves in `backend_type` - for example `spock supervisor`, `spock manager 16384`, and `spock apply 16384:1`. Compare the number of background workers in use against the limit: ```sql SELECT current_setting('max_worker_processes')::int AS worker_limit, count(*) AS in_use FROM pg_stat_activity WHERE backend_type NOT IN ( 'client backend', 'walsender', 'autovacuum launcher', 'autovacuum worker', 'checkpointer', 'background writer', 'walwriter', 'walreceiver', 'walsummarizer', 'archiver', 'startup', 'io worker', 'standalone backend'); ``` The exclusion list names the client backends and auxiliary processes that do not draw on `max_worker_processes`; everything left over does. The list of auxiliary process types changes between major versions, so check it against [`pg_stat_activity`](https://www.postgresql.org/docs/current/monitoring-stats.html#MONITORING-PG-STAT-ACTIVITY-VIEW) for your version. ## Diagnosing Exhaustion {#diagnosing-exhaustion} **`worker registration failed, you might want to increase max_worker_processes setting`** Postgres refused to register a background worker because `max_worker_processes` is fully allocated. Recompute with the formula above, remembering that parallel query workers share the pool, and restart. **`could not register spock worker: all background worker slots are already used`** Spock's own worker-tracking array — sized to `max_worker_processes` at startup — has no free entry. A worker that exits cleanly releases its entry immediately, but a worker that *crashes* leaves its entry reserved for the same database until that database's manager (or the supervisor) reclaims it. Repeated worker crashes across many different databases can therefore exhaust the array while Postgres still reports free worker slots. Check the server log for the preceding crash and address that; raising `max_worker_processes` enlarges the array but does not fix the underlying failures. **Subscription stuck in `initializing`** Usually `max_replication_slots` or `max_wal_senders` on the *provider*. A subscription that is initializing needs a slot and walsender for its sync worker in addition to those already held by its apply stream, which is why a cluster that replicates fine in steady state can fail to add or resync a table. See [Troubleshooting](/docs/spock/upstream/spock/troubleshooting/). **Increasing replication lag with idle apply workers** If `spock.lag_tracker` shows growing lag but apply workers are not running, check the server log for worker registration failures — the manager retries registration on a delay, so an exhausted worker pool presents as intermittent apply rather than a hard stop. --- [Upstream source](https://github.com/pgEdge/spock/blob/d05e2e2b6a82796d86e3c16ffb0d3fc38b1b329c/docs/sizing.md) · `d05e2e2b6a82` · Copyright (c) 2021–2026, pgEdge, Inc.; portions Copyright the PostgreSQL Global Development Group and The Regents of the University of California. [PostgreSQL License](/docs/spock/upstream/about/license/). [PG.CENTER edition](https://github.com/pgsty/doc.pg.center/blob/4410c32dc9186a22859008303f474b72a779f583/content/pgedge/spock/sizing.md) --- Backlinks: - [Quick start](/docs/spock/upstream/quick-start/) - [Spock](/docs/spock/upstream/spock/) - [Configuration](/docs/spock/upstream/spock/configuration/) - [Getting started](/docs/spock/upstream/spock/getting-started/) - [Installation](/docs/spock/upstream/spock/installation/) - [Slot failover](/docs/spock/upstream/spock/logical-slot-failover/) - [Release notes](/docs/spock/upstream/spock/spock-release-notes/) - [Troubleshooting](/docs/spock/upstream/spock/troubleshooting/) - [Two-node tutorial](/docs/spock/upstream/spock/two-node/) ================ Source: https://mimus.pgsty.com/docs/spock/upstream/spock/configuration/index.md ================ # Configuring Spock > Add the following postgresql.conf settings on each node in your Spock replication scenario before creating the Spock extension: --- LLMS index: [llms.txt](/llms.txt) --- > The upstream Spock manual covers 6.0.0-beta.2 and includes 5.0 maintenance notes. For deployment, configuration and recovery on Mimus, use [Spock 5.0.15](/docs/spock/). Add the following `postgresql.conf` settings on each node in your Spock replication scenario before creating the Spock extension: ```sql wal_level = 'logical' max_worker_processes = 20 # supervisor + slot sync worker + one per # database + one per subscription + sync workers, # and shared with parallel query - see the # sizing guide max_replication_slots = 10 # two per subscriber, per replicated database, # plus one per physical standby; 10 covers a # four-node mesh replicating one database max_wal_senders = 10 # keep equal to max_replication_slots shared_preload_libraries = 'spock' track_commit_timestamp = on # needed for conflict resolution output_plugin_libraries = 'pgoutput, test_decoding, spock_output' # only on servers that have this parameter; see below ``` These values suit a small cluster of two or three nodes replicating a single database. Subscriptions - and the workers, walsenders, and slots that follow from them - scale with node count *multiplied by* the number of replicated databases, so an instance replicating several databases needs proportionally more of each. For anything larger, or for an instance hosting several databases or other extensions that use background workers, size each parameter with the formulas in [Sizing Postgres Resources for Spock](/docs/spock/upstream/spock/sizing/). All three require a server restart to change. > [!WARNING] `output_plugin_libraries` > > A 2026 PostgreSQL security fix (CVE-2026-6471, back-patched to every > supported major) added the `output_plugin_libraries` parameter, and a > library may no longer be used as an output plugin unless it is listed > there. Its default, `'pgoutput, test_decoding'`, does not include > `spock_output`, so on such a server logical decoding fails with: > > ``` > ERROR: library "spock_output" may not be used as an output plugin > ``` > > The check runs every time decoding starts, not only when the slot is > created, so an established cluster stops replicating after a minor-version > upgrade too. Add `spock_output` to the list, keeping the core defaults, as > shown above, on every node — including standbys, which need it once > promoted. > > Only set the parameter if your server has it. On a PostgreSQL release > predating the fix an unrecognised parameter in `postgresql.conf` stops the > server from starting at all. To check, run against a server that is up: > > ```sql > SELECT current_setting('output_plugin_libraries', true); > ``` > > A NULL result means the parameter does not exist and must not be set. You > can also ask the binary, with no server running: > > ```bash > postgres --describe-config | grep '^output_plugin_libraries' > ``` > After modifying the parameters and restarting the Postgres server with your OS-specific restart command, connect with psql and create the Spock extension: ```sql [pg18]$ sudo -u postgres psql -U postgres -p 5432 psql (18.1) Type "help" for help. postgres=# CREATE EXTENSION spock; CREATE EXTENSION ``` You will also need to modify your [`pg_hba.conf` file](https://www.postgresql.org/docs/18/auth-pg-hba-conf.html) to allow logical replication connections from localhost and between nodes. Logical replication connections are treated by `pg_hba.conf` as regular connections to the provider database. After modifying the `pg_hba.conf` file on each node, reload the server configuration to apply the changes (no restart required): ```sql SELECT pg_reload_conf(); ``` ## Advanced Configuration Options for Spock {#advanced-configuration-options-for-spock} You can use the following configuration parameters (GUCs) on the psql command line with a `SET` statement or in a Postgres configuration file (for example, `postgresql.conf`) to configure a Spock installation. ### `spock.allow_ddl_from_functions` {#spockallow_ddl_from_functions} `spock.allow_ddl_from_functions` enables spock to automatically replicate DDL statements that are called within functions to also be automatically replicated. This can be turned `off` if these functions are expected to run on every node. When this is set to `off`, statements replicated from functions adhere to the same rule previously described for `include_ddl_repset`. If a table possesses a defined primary key, it will be added into the `default` replication set; alternatively, they will be added to the `default_insert_only` replication set. ### `spock.apply_change_logging` {#spockapply_change_logging} `spock.apply_change_logging` controls per-change JSON logging by the apply worker. After each change is successfully applied locally, a single JSON object is written to the PostgreSQL server log (at `LOG` level) so that operators can correlate replayed changes with their origin and commit timestamp. This is intended for debugging and auditing; it adds log volume proportional to the apply workload, so leave it at the default in normal operation. The following values are possible: - `none` (the default) - no per-change logging. - `key_only` - for each `INSERT`/`UPDATE`/`DELETE`, log the action, schema-qualified table, primary-key values, origin, and commit timestamp. - `verbose` - all of the above, plus the old and new row data for each change. Replicated DDL is logged (with its SQL text) in both `key_only` and `verbose` modes. This option can be set by a superuser via `SET`, or reloaded with the `SIGHUP` mechanism (for example, `SELECT pg_reload_conf()`); a server restart is not required. ### `spock.channel_counters` {#spockchannel_counters} `spock.channel_counters` is a boolean value (the default is `true`) that enables or disables the Spock channel statistic information collection. This option can only be set when the postmaster starts. ### `spock.check_all_uc_indexes` {#spockcheck_all_uc_indexes} > [!NOTE] > > This feature is experimental and `OFF` by default. Use this feature at > your own risk. > This parameter enhances conflict resolution during `INSERT` operations in scenarios where a row exists that meets unique constraints defined on the table (rather than primary keys or replication identity). If this GUC is `enabled`, Spock will continue to check unique constraint indexes, after checking the primary key or replica identity index. Only one conflict will be resolved, using Last-Write-Wins logic. This includes the primary key or replica identity index. If a second conflict occurs, the outcome is recorded in the `spock.resolutions` table if `spock.save_resolutions` is enabled; otherwise it is not persisted. Partial unique constraints are supported, but nullable unique constraints are not. Deferrable constraints are not supported, are filtered out and are not checked, and therefore may still cause an exception during the final commit. Unique constraint indexes are checked in OID order, after the primary key. It is therefore possible for the resolution of a unique constraint to change the primary key value. Child tables / foreign keys are not checked or handled. Therefore, if resolving a unique constraint changes the primary key value, you can inadvertently create orphaned foreign key records. ### `spock.conflict_resolution` {#spockconflict_resolution} `spock.conflict_resolution` sets the resolution method for any detected conflicts between local data and incoming changes. The only supported value in current Spock releases is: - `last_update_wins` (the default) - the version of data with the newest commit timestamp will be kept (this can be either the local or the remote version). To enable conflict resolution, the `track_commit_timestamp` setting must be enabled. ### `spock.deny_all_ddl` {#spockdeny_all_ddl} `spock.deny_all_ddl` is a boolean value (the default is `false`) that enables or disables the execution of DDL statements within a Spock configured cluster. This option can be set at postmaster startup, with the SIGHUP mechanism, or on the command line with SQL if you're a superuser. ### `spock.enable_ddl_replication` {#spockenable_ddl_replication} `spock.enable_ddl_replication` enables [automatic replication](/docs/spock/upstream/spock/managing/spock-autoddl/) of ddl statements through the `default` replication set. ### `spock.exception_behaviour` {#spock-exception_behaviour} Use this GUC to specify the commit behavior of Postgres when it encounters an ERROR within a transaction: - `transdiscard` (the default) - set `spock.exception_behaviour` to `transdiscard` to instruct the server to discard a transaction if any operation within that transaction returns an `ERROR`. - `discard` - set `spock.exception_behaviour` to `discard` to continue processing (and replicating) without interrupting server use; the server will commit any operation (any portion of a transaction) that does not return an `ERROR` statement. - `sub_disable` - set `spock.exception_behaviour` to `sub_disable` to disable the subscription for the node on which the exception was reported; transactions for the disabled node will be added to a queue that is written to the WAL log file; when the subscription is enabled, replication will resume with the transaction that caused the exception, followed by the other queued transactions; you can use the `spock.sub_alter_skiplsn` function to skip the transaction that caused the exception and resume processing with the next transaction in the queue. Note that the value you choose for `spock.exception_behaviour` could potentially result in a large WAL log if transactions are allowed to accumulate. ### `spock.event_history_size` {#spockevent_history_size} `spock.event_history_size` sets how many recent events the `spock.events` view keeps in shared memory. Once the history is full the oldest event is dropped for each new one. The parameter accepts values from `16` to `1048576` (the default is `1024`) and can only be set when the postmaster starts. ### `spock.exception_logging` {#spockexception_logging} Use this GUC to specify which operations or transactions are written to the exception log table: - `all` (the default) - set `spock.exception_logging` to `all` to instruct the server to record all transactions that contain one or more failed operations in the `spock.exception_log` table; note that this setting will log all operations that are part of a transaction if one operation fails. - `discard` - add a row to the `spock.exception_log` table for any discarded operation; successful transactions are not logged. - `none` - instructs the server to not log any operation or transactions to the exception log table. ### `spock.exception_replay_queue_size` - DEPRECATED {#spockexception_replay_queue_size---deprecated} This parameter will not be supported after version 5.X. When Spock encounters a replication exception, it attempts to resolve the exception by entering exception-handling mode, based on the value of `spock.exception_behaviour`. Spock then writes any transaction up to a default size of `4MB` to memory, and the apply worker replays the transaction from memory. This provides a massive speed and performance increase in the handling of the vast majority of exceptions. The memory size is configurable with `spock.exception_replay_queue_size`. Now, Spock performs as specified by the [`spock.exception_behaviour`](#spock-exception_behaviour) parameter. ### `spock.extra_connection_options` {#spockextra_connection_options} You can use the `spock.extra_connection_options` parameter in the `postgresql.conf` file to assign connection options that apply to all connections made by Spock. This can be a useful place to set up custom keepalive options, etc. `spock` defaults to enabling TCP keepalives to ensure that it notices when the upstream server disappears unexpectedly. To disable them add `keepalives = 0` to `spock.extra_connection_options`. ### `wal_sender_timeout` {#wal_sender_timeout} For Spock replication, set `wal_sender_timeout` to a conservative value such as `5min` (300000ms) on each node in `postgresql.conf`: ```ini wal_sender_timeout = '5min' ``` The default PostgreSQL value of `60s` can cause spurious disconnects when the subscriber is busy applying a large transaction and cannot send feedback in time. A higher value gives the apply worker enough headroom while still detecting truly dead connections. Liveness detection is primarily handled by TCP keepalives, and `spock.apply_idle_timeout` provides an additional subscriber-side safety net. ### `spock.apply_idle_timeout` {#spockapply_idle_timeout} Maximum idle time (in seconds) before the apply worker reconnects to the provider. This acts as a safety net for detecting a hung walsender that keeps the TCP connection alive but stops sending data. The timer resets on any received message. Set to `0` to disable and rely solely on TCP keepalive for liveness detection. Default: `300` (5 minutes). ```ini spock.apply_idle_timeout = 300 ``` ### `spock.sync_timeout` {#spocksync_timeout} Overrides the time (in seconds) budgeted for a single synchronisation wait in the node management routines - waiting for a sync event to arrive on a peer, waiting for a node to catch up, or waiting for a subscription to start replicating. Default: `0`, meaning each routine keeps its own built-in limit (3 minutes). Only a positive value takes effect, so leaving this unset preserves the behaviour those routines have always had. Raise it on large databases. The built-in limits are sized for small clusters, where a node joins in seconds; when catchup legitimately takes minutes or hours, the routines fail with a timeout long before the work is done. It can be raised for a single operation rather than cluster-wide: ```sql SET spock.sync_timeout = '2h'; CALL spock.add_node(...); ``` This bounds a whole wait, not an individual probe of a remote node. Routines that additionally bound each remote probe - so that one unresponsive peer cannot consume the entire budget - keep their own, much smaller limit for that purpose. ```ini spock.sync_timeout = 0 ``` ### `spock.read_retry_count` {#spockread_retry_count} Number of times the apply worker re-reads the local relation when a row targeted by a remote `UPDATE` or `DELETE` is not yet visible. On each retry the apply worker waits for any concurrently-applying transaction to finish and then searches the local relation again. If the row is still missing after the configured number of retries, the apply worker falls through to the standard row-missing handling path (conflict resolution and/or the exception handler, depending on the configured [`spock.exception_behaviour`](#spock-exception_behaviour)). Set to `0` to disable retries entirely (the row-missing path runs immediately). Valid range is `0` to `100`. Default: `5`. Changes take effect on `SIGHUP` (for example, `SELECT pg_reload_conf()`); a server restart is not required. ```ini spock.read_retry_count = 5 ``` ### Logical Slot Failover (HA Standby) {#logical-slot-failover-ha-standby} Spock creates logical replication slots on each provider node. For high availability with a physical standby, these slots must be synchronized to the standby so that replication can resume without data loss after a failover. See [Logical Slot Failover](/docs/spock/upstream/spock/logical-slot-failover/) for full setup instructions, including a runbook step for clearing `synchronized_standby_slots` on the promoted node after a failover. The behaviour depends on the PostgreSQL version: | PostgreSQL | Slot sync mechanism | Spock worker | |---|---|---| | 15, 16 | Spock built-in `spock_failover_slots` worker | Runs on every node | | 17 | Spock worker OR native `sync_replication_slots` | Spock worker yields to native if enabled | | 18+ | Native `sync_replication_slots` (required) | Not registered | {.wide .expand} Whichever mechanism applies, a slot sync worker is present on every node, primary and standby alike, so include one in the worker budget - see [Sizing Postgres Resources for Spock](/docs/spock/upstream/spock/sizing/). #### PostgreSQL 17 and Later (Native Slot Sync) {#postgresql-17-and-later-native-slot-sync} On PostgreSQL 17+, Spock marks every logical slot with the `FAILOVER` flag at creation time. PostgreSQL's built-in slotsync worker then synchronizes those slots automatically. On **PostgreSQL 17**, Spock's worker only yields to native slotsync when you set `sync_replication_slots = on` (below). On **PostgreSQL 18+**, Spock's own failover worker is not registered, so the native mechanism is required. Either way, PostgreSQL's own slot synchronization must be configured. To switch a PostgreSQL 17 standby that Spock's worker has been syncing, follow [Switching a PostgreSQL 17 standby from the Spock worker](/docs/spock/upstream/spock/logical-slot-failover/#switching-a-postgresql-17-standby-from-the-spock-worker); setting `sync_replication_slots = on` alone is not enough. First create the physical replication slot on the primary. The standby streams through it, and its `catalog_xmin` (fed back via `hot_standby_feedback`) is what protects the synchronized logical slots from being invalidated: ```sql SELECT pg_create_physical_replication_slot('physical_slot_name'); ``` **Primary (`postgresql.conf`):** ```ini # Hold logical walsenders back until the standby has confirmed the changes. synchronized_standby_slots = 'physical_slot_name' ``` **Standby (`postgresql.conf`):** ```ini sync_replication_slots = on # enable the native slotsync worker hot_standby_feedback = on # required; pins the primary's catalog vacuum primary_slot_name = 'physical_slot_name' # the physical slot created above primary_conninfo = 'host= dbname= ...' # must include dbname ``` Only logical slots created with `failover = true` are synchronized. Spock 6.0.0 sets that flag when it creates a slot, and the upgrade from 5.x sets it on existing slots; see [Upgrading Spock to 6.0.0](/docs/spock/upstream/spock/logical-slot-failover/#upgrading-spock-to-600) for any it skips. After a failover, subscribers only need to update their `host=` in the connection string — replication resumes from the last synchronized LSN with no data loss. **However**, if the promoted node has `synchronized_standby_slots` set, you must clear or update it first — otherwise its walsenders wait forever on the now-orphaned physical slot(s) and logical replication to subscribers freezes. See the [runbook in Logical Slot Failover](/docs/spock/upstream/spock/logical-slot-failover/#runbook-clear-synchronized_standby_slots-after-promotion) for when this applies and the exact steps. #### PostgreSQL 15, 16, and 17 (Spock Built-in Worker) {#postgresql-15-16-and-17-spock-built-in-worker} On PostgreSQL 15, 16, and 17, Spock's `spock_failover_slots` background worker handles slot synchronization. On PostgreSQL 17 it yields to the native slotsync worker when `sync_replication_slots = on` is enabled. Configure it with the GUCs below. ### `spock.synchronize_slot_names` {#spocksynchronize_slot_names} List of slot name patterns to synchronize from primary to physical standby. Accepts name prefixes (`name:foo`) or LIKE patterns (`name_like:spock%`). Default: `name_like:%%` (synchronize all logical slots). ```ini spock.synchronize_slot_names = 'name_like:%%' ``` Used on PostgreSQL 15, 16, and 17 (when `sync_replication_slots` is not enabled). On PostgreSQL 17 with native slotsync active, or on PostgreSQL 18+, this setting is ignored. ### `spock.drop_extra_slots` {#spockdrop_extra_slots} When `on` (the default), the `spock_failover_slots` worker drops any slots on the standby that do not match `spock.synchronize_slot_names`. ```ini spock.drop_extra_slots = on ``` ### `spock.primary_dsn` {#spockprimary_dsn} Connection string used by the `spock_failover_slots` worker to connect to the primary and read slot state. If empty, `primary_conninfo` from `postgresql.conf` is used. ```ini spock.primary_dsn = '' ``` ### `spock.pg_standby_slot_names` {#spockpg_standby_slot_names} Comma-separated list of physical replication slot names that must confirm durable flush of a given LSN before the walsender is allowed to replicate logical changes beyond that LSN. This prevents a physical standby from falling behind a logical subscriber. ```ini spock.pg_standby_slot_names = 'physical_slot_1,physical_slot_2' ``` Used on every supported PostgreSQL version, with or without native slot sync. PostgreSQL's own `synchronized_standby_slots` has no equivalent of `spock.standby_slots_min_confirmed`: it waits for every slot it names, so with it one standby that is down stops logical replication to every subscriber. Use only one of them; setting both is redundant. For a failover slot `synchronized_standby_slots` is applied first and waits for all of its slots, so when it names every slot listed here this setting adds nothing, and the walsender logs that; a slot listed only here still counts. A listed slot that does not exist can never confirm: with the default `-1` the walsender waits until `wal_sender_timeout`, logs a warning naming the slot, and starts over, so after a promotion either create the slots on the new primary or clear the setting there. ### `spock.standby_slots_min_confirmed` {#spockstandby_slots_min_confirmed} Number of slots from `spock.pg_standby_slot_names` that must confirm a given LSN before logical replication is allowed to proceed. The default `-1` requires all listed slots to confirm. `0` disables the check. ```ini spock.standby_slots_min_confirmed = -1 ``` With a value lower than the number of listed slots, subscribers can receive changes that some standbys do not have yet. After a failure, promote the standby with the highest `pg_last_wal_receive_lsn()`: it has every change sent to a subscriber. Promoting a standby that is further behind leaves subscribers with rows the new primary never had. ### `spock.failover_slots_naptime` {#spockfailover_slots_naptime} How long the `spock_failover_slots` worker sleeps between slot-synchronization passes, in milliseconds. A smaller value keeps the standby's synchronized slots closer to the primary — narrowing the window in which a promotion can find a stale slot — at the cost of more frequent sync passes. Default: `1000` (1s). Range: `1`–`3600000`. Settable at runtime with `SIGHUP` (reload). ```ini spock.failover_slots_naptime = 1000 ``` Used on PostgreSQL 15, 16, and 17 (when `sync_replication_slots` is not enabled) — the versions on which the built-in worker performs the sync. ### `spock.failover_slots_feedback_naptime` {#spockfailover_slots_feedback_naptime} Shorter retry interval, in milliseconds, used instead of `spock.failover_slots_naptime` while the standby has not yet received or fed back the WAL a slot needs. Default: `10000` (10s). Range: `1`–`3600000`. Settable at runtime with `SIGHUP` (reload). ```ini spock.failover_slots_feedback_naptime = 10000 ``` ### `spock.failover_slots_recreate_invalidated` {#spockfailover_slots_recreate_invalidated} Whether the `spock_failover_slots` worker drops and recreates a synchronized slot whose copy on the standby was invalidated, for example because the standby removed WAL or the primary removed catalog rows the copy still needed. Such a copy looks current but cannot serve a subscriber after a promotion. With the default `on`, the worker reports it with a WARNING, drops it and creates it again from the primary. The new copy stays a temporary slot until the primary's slot has caught up with it, while the worker keeps synchronizing the other slots; if the standby is promoted before then, the copy is dropped. A temporary copy belongs to the worker process: if the worker exits for any reason, for example because the primary is restarting and cannot be reached, the copy is dropped with it, and the worker that the postmaster starts a minute later creates it again at the standby's position of that time, which the primary's slot has to pass again. If a temporary copy is invalidated while the worker holds it, PostgreSQL terminates the worker to release the slot, with the same effect. With `off`, the worker leaves the copy as it is and reports it once, so it can be looked at before anything is dropped; it is recreated on the first pass after the setting is turned back on. Settable at runtime with `SIGHUP` (reload). Used on PostgreSQL 15, 16, and 17 (when `sync_replication_slots` is not enabled). On PostgreSQL 17 with native slotsync active, or on PostgreSQL 18+, this setting is ignored. ```ini spock.failover_slots_recreate_invalidated = on ``` ### `spock.failover_slots_database` {#spockfailover_slots_database} > [!NOTE] > The instructions below describe the 6.0.0-beta.2 snapshot. On the 5.0 maintenance branch, `v5.0.15-rc.2` adds connection retries and shortens the worker restart delay to 15 seconds. See the [5.0.15 candidate notes](/docs/spock/upstream/spock/spock-release-notes/#spock-5015-rc) and its [configuration reference](https://github.com/pgEdge/spock/blob/e710faa6fe21126d898fa660e9b6dc8ed0da9438/docs/configuring.md). The database the `spock_failover_slots` worker connects to on the standby. A synchronized slot copy holds the primary's positions, but not the snapshot the primary saved for the slot, which physical replication does not carry. After a promotion, decoding from such a copy has to build a new snapshot, and transactions that commit before it is consistent are never sent to the subscriber. When this setting names a database, the worker decodes each copy's WAL on the standby, as PostgreSQL 17's native slot sync does, so the copy only points at positions where the standby has saved a snapshot of its own. A new copy is made persistent only once that snapshot is consistent. While a transaction older than a copy's `restart_lsn` is still open on the primary, decoding cannot reach a consistent snapshot; the copy is reported once and left as it is until the transaction ends, and the worker goes on with the other slots. The check is off by default. While the setting is empty, every copy is synchronized without it, as in earlier releases, and is reported once (a WARNING on PostgreSQL 16 and 17, a LOG entry on 15); after a promotion, such a copy can still skip transactions the old primary committed shortly before the failover. On PostgreSQL 16 this must be the database the synchronized slots belong to, normally the Spock database. Copies in another database are synchronized without the check, reported once with a WARNING, and carry the same risk. The worker connects to one database only, so with Spock in several databases on PostgreSQL 16, name the most important one; the slots of the others are not protected. On PostgreSQL 17, any one database covers the slots of every database. The standby also needs `wal_level = logical`. PostgreSQL 15 cannot decode WAL on a standby, so there the check is not available and each copy is noted once in the log instead. Default: empty. Requires a restart. On PostgreSQL 16 and 17 the worker stays connected to this database on every node where the setting is present, including a primary, where it otherwise sleeps, and a PostgreSQL 17 standby using native slot sync. As with any open connection, `DROP DATABASE`, `ALTER DATABASE ... RENAME` and `CREATE DATABASE ... TEMPLATE` on that database then fail. Stopping the worker frees the database only until it restarts 60 seconds later; use `DROP DATABASE ... WITH (FORCE)`, or clear the setting and restart the server. If connecting fails, for example because the database does not exist, the worker reports it, carries on without the check, and does not try again until the server is restarted. The same happens when the database is dropped on the primary: replaying the drop on the standby ends the worker, the restarted worker cannot connect to the database, and the worker after that keeps synchronizing slots without the check. The check is made on PostgreSQL 16 and 17 (when `sync_replication_slots` is not enabled). On PostgreSQL 17 with native slot sync active, the worker still connects but makes no check. On PostgreSQL 17, native slot sync is the recommended setup; it gives every copy a consistent snapshot without this setting. Turning on `sync_replication_slots` alone is not enough to switch: native slot sync has further requirements and will not take over the copies the Spock worker made, so until those are dropped most or all slots stop being synchronized. See [Switching a PostgreSQL 17 standby from the Spock worker](/docs/spock/upstream/spock/logical-slot-failover/#switching-a-postgresql-17-standby-from-the-spock-worker). On PostgreSQL 15 and 18+, this setting is ignored. On PostgreSQL 17, once the worker has taken over from native slot sync, a copy that native slot sync made is synchronized like any other, but a standby cannot drop it. If the primary drops that slot, the worker leaves the copy and reports it once; it is dropped on the promoted node. ```ini spock.failover_slots_database = 'pgedge' ``` ### `spock.include_ddl_repset` {#spockinclude_ddl_repset} `spock.include_ddl_repset` enables spock to automatically add tables to replication sets at the time they are created on each node. Tables with primary keys will be added to the `default` replication set, and tables without primary keys will be added to the `default_insert_only` replication set. Altering a table to add or remove a primary key will make the correct adjustment to which replication set the table is part of. Setting a table to unlogged will remove it from replication. Detaching a partition will not remove it from replication. ### `spock.log_origin_change` {#spocklog_origin_change} `spock.log_origin_change` indicates whether changes to a row's origin should be logged to the PostgreSQL log. Rows may be being updated locally by regular SQL operations, or by replication from apply workers. Note that rows that are changed locally (not from replication) have the origin value of `0`. This is distinct from an unavailable or unknown origin: a `NULL` value in `spock.resolutions.local_origin`, or `unknown` in PostgreSQL logs, indicates that the origin metadata could not be determined — it does not mean the change was local. For example: ```sql -- Rows resolved from a locally-originated conflict (origin = 0) SELECT * FROM spock.resolutions WHERE local_origin = 0; -- Rows where origin metadata was unavailable at resolution time SELECT * FROM spock.resolutions WHERE local_origin IS NULL; ``` The default of `none` is recommended because otherwise the amount of entries may become numerous. The other options allow for monitoring when updates occur outside expected patterns. The following configuration values are possible: - `none` (the default) - do not log any origin change information. - `remote_only_differs` - only log origin changes when the existing row was from one remote publisher and was changed by another remote publisher. - `since_sub_creation` - log origin changes whether a publisher changed a row that was previously from another publisher or updated it locally, but only since the time when the subscription was created. ### `spock.log_verbosity` {#spocklog_verbosity} `spock.log_verbosity` controls the verbosity of Spock's own debug log output. Spock emits internal `DEBUG1`/`DEBUG2` messages that are normally silent, because PostgreSQL's `log_min_messages` typically defaults to `warning`. Lowering `log_min_messages` globally would surface those messages, but it would also flood the log with unrelated PostgreSQL debug output. Instead, this setting *promotes* Spock's own debug messages to `LOG` level (which is written to the server log under any normal `log_min_messages` setting), without changing `log_min_messages`. The value controls how much detail is promoted: - `normal` (the default) - promote nothing; Spock's `DEBUG1`/`DEBUG2` messages keep their native (normally silent) levels. - `debug1` - promote Spock's `DEBUG1` messages to `LOG`. - `debug2` - promote both Spock's `DEBUG1` and `DEBUG2` messages to `LOG`. This option can be set by a superuser via `SET`, or reloaded with the `SIGHUP` mechanism (for example, `SELECT pg_reload_conf()`); a server restart is not required. ### `spock.non_conflicting_inserts` {#spocknon_conflicting_inserts} `spock.non_conflicting_inserts` is a boolean value (the default is `off`) with which you assert that a replicated `INSERT` can never collide with a row that already exists locally - because, for example, every node generates keys from its own range. Applying an `INSERT` normally costs two pieces of work that only a possible collision justifies: a lookup for the conflicting local row, and a speculative insertion that lets the unique indexes report a duplicate instead of raising one. When this parameter is `on`, the apply worker skips both and inserts the row directly. Nothing checks the assertion. If a collision does occur, the index raises `duplicate key value violates unique constraint`, the transaction is aborted, and the outcome is decided by [`spock.exception_behaviour`](#spock-exception_behaviour) - the row is not resolved by `spock.conflict_resolution` and is not recorded in `spock.resolutions`. Leave this parameter `off` unless collisions are impossible by design rather than merely rare. This option can only be set when the postmaster starts. ### `spock.save_resolutions` {#spocksave_resolutions} `spock.save_resolutions` is a boolean value (the default is `false`) that logs all conflict resolutions to the `spock.resolutions` table. This option can only be set when the postmaster starts. ### `spock.resolutions_retention_days` {#spockresolutions_retention_days} `spock.resolutions_retention_days` controls how long rows are kept in the `spock.resolutions` table before the apply worker automatically deletes them. The default is `100` days. Set to `0` to disable automatic cleanup entirely, in which case rows accumulate indefinitely until removed manually. This setting takes effect on `pg_reload_conf()` (no restart required). ```ini spock.resolutions_retention_days = 100 ``` ### `spock.stats_max_entries` {#spockstats_max_entries} `spock.stats_max_entries` specifies the maximum number of entries that can be stored into the Spock channel statistic. This option can only be set when the postmaster starts. The parameter accepts values from `-1` to `INT_MAX` (the default is `-1`). ### `spock.temp_directory` {#spocktemp_directory} `spock.temp_directory` defines the system path where temporary files needed for schema synchronization are written. This path needs to exist and be writable by the user running Postgres. The default is `empty`, which tells Spock to use the default temporary directory based on environment or operating system settings. --- [Upstream source](https://github.com/pgEdge/spock/blob/d05e2e2b6a82796d86e3c16ffb0d3fc38b1b329c/docs/configuring.md) · `d05e2e2b6a82` · Copyright (c) 2021–2026, pgEdge, Inc.; portions Copyright the PostgreSQL Global Development Group and The Regents of the University of California. [PostgreSQL License](/docs/spock/upstream/about/license/). [PG.CENTER edition](https://github.com/pgsty/doc.pg.center/blob/4410c32dc9186a22859008303f474b72a779f583/content/pgedge/spock/configuration.md) --- Backlinks: - [Spock](/docs/spock/upstream/spock/) - [Getting started](/docs/spock/upstream/spock/getting-started/) - [Installation](/docs/spock/upstream/spock/installation/) - [Limitations](/docs/spock/upstream/spock/limitations/) - [Tutorial: Updating the Postgres Version with a Rolling Update](/docs/spock/upstream/spock/modify/zodan/zodan-rolling-pg-version-tutorial/) - [Tutorial: Adding a Node to a Cluster with Zero Downtime](/docs/spock/upstream/spock/modify/zodan/zodan-tutorial/) - [Release notes](/docs/spock/upstream/spock/spock-release-notes/) - [Troubleshooting](/docs/spock/upstream/spock/troubleshooting/) ================ Source: https://mimus.pgsty.com/docs/spock/upstream/spock/managing/index.md ================ # Managing a Spock Installation > The Spock extension is a powerful addition to any PostgreSQL installation; management features of the Spock extension allow you to seamlessly: --- LLMS index: [llms.txt](/llms.txt) --- > The upstream Spock manual covers 6.0.0-beta.2 and includes 5.0 maintenance notes. For deployment, configuration and recovery on Mimus, use [Spock 5.0.15](/docs/spock/). The Spock extension is a powerful addition to any PostgreSQL installation; management features of the Spock extension allow you to seamlessly: * [replicate partitioned tables](/docs/spock/upstream/spock/managing/partition-mgmt/). * create logical [row-based data filters](/docs/spock/upstream/spock/managing/filtering/). * set a cluster to [READ-ONLY mode](/docs/spock/upstream/spock/managing/read-only/); this restricts non-superusers to read-only operations, while superusers can still perform both read and write operations. * use a [trigger](/docs/spock/upstream/spock/managing/repset-trigger/) to manage replication set membership. * use [Snowflake sequences](/docs/spock/upstream/spock/managing/snowflake/) for sequence management in a distributed cluster. * use [the Lolor extension](/docs/spock/upstream/spock/managing/lolor/) to replicate large objects. * enable [automatic DDL replication](/docs/spock/upstream/spock/managing/spock-autoddl/). --- [Upstream source](https://github.com/pgEdge/spock/blob/d05e2e2b6a82796d86e3c16ffb0d3fc38b1b329c/docs/managing/index.md) · `d05e2e2b6a82` · Copyright (c) 2021–2026, pgEdge, Inc.; portions Copyright the PostgreSQL Global Development Group and The Regents of the University of California. [PostgreSQL License](/docs/spock/upstream/about/license/). [PG.CENTER edition](https://github.com/pgsty/doc.pg.center/blob/4410c32dc9186a22859008303f474b72a779f583/content/pgedge/spock/managing/_index.md) --- Section pages: - [Automatic DDL Replication](/docs/spock/upstream/spock/managing/spock-autoddl/): The spock extension can automatically replicate DDL statements. - [Automatically Assigning Tables to Replication Sets](/docs/spock/upstream/spock/managing/repset-trigger/): Automatic DDL replication is a great alternative to using a trigger to manage replication sets, but if you do need to dynamically modify replication rules, column or row filters, or partition filters, this trigger might be useful. - [Filtering](/docs/spock/upstream/spock/managing/filtering/): Spock allows row based filtering on both the provider side and the subscriber side. - [Replicating Partitioned Tables](/docs/spock/upstream/spock/managing/partition-mgmt/): By default, when you add a partitioned table to a Spock replication set, Spock will include all the current partitions of a partitioned table. - [Using LOLOR to Manage Large objects](/docs/spock/upstream/spock/managing/lolor/): PostgreSQL's logical decoding facility does not support decoding changes to large objects; we recommend instead using the LOLOR extension to manage large objects. - [Using Spock in Read-Only Mode](/docs/spock/upstream/spock/managing/read-only/): Spock supports operating a node in read-only mode. - [Using Spock with Snowflake Sequences](/docs/spock/upstream/spock/managing/snowflake/): The Snowflake extension provides a sequence-based unique ID solution to replace the Postgres built-in bigserial data type in distributed replication clusters. ================ Source: https://mimus.pgsty.com/docs/spock/upstream/spock/managing/spock-autoddl/index.md ================ # Automatic DDL Replication > The spock extension can automatically replicate DDL statements. --- LLMS index: [llms.txt](/llms.txt) --- > The upstream Spock manual covers 6.0.0-beta.2 and includes 5.0 maintenance notes. For deployment, configuration and recovery on Mimus, use [Spock 5.0.15](/docs/spock/). The spock extension can automatically replicate DDL statements. To enable automatic DDL replication, set the following parameters to `on`: * `spock.enable_ddl_replication` enables replication of ddl statements through the default replication set. Some DDL statements are intentionally not replicated (like `CREATE DATABASE`). Other DDL statements are replicated, but can lead to replication issues (like the `CREATE TABLE... AS...` statement). In the case of `CREATE TABLE... AS...`, the DDL statement is replicated before the table is added to the replication set, leading to potential data irregularities. Some DDL statements are replicated, but might potentially create an issue in a 3+ node cluster (ie. `DROP TABLE`). * `spock.include_ddl_repset` enables spock to automatically add tables to replication sets at the time they are created on each node. Tables with Primary Keys will be added to the `default` replication set, and tables without Primary Keys will be added to the `default_insert_only` replication set. Altering a table to add or remove a primary key will also modify which replication set the table is a member of. Setting a table to `unlogged` removes the table from replication. Detaching a partition will not remove a table from replication. * `spock.allow_ddl_from_functions` enables spock to automatically replicate DDL statements that are called within functions. Set `spock.allow_ddl_from_functions` to `off` if each function is expected to execute on every node. When set to `off`, statements replicated from functions adhere to the same rule described for `include_ddl_repset`. If a table possesses a primary key, it will be added into the `default` replication set; alternatively, they will be added to the `default_insert_only` replication set. To completely block all DDL across the cluster (including DDL that would otherwise be replicated automatically), use: * `spock.deny_all_ddl` - a boolean value, default `false`. When set to `true`, Spock rejects any DDL statement executed on the node. This is useful as a guard during sensitive maintenance windows or while a node is being added or repaired. The setting can be changed by a superuser at runtime (`PGC_SUSET`); a server reload is not required. It's best to set these parameters to `on` only when the database schema matches exactly on all nodes - either when all databases have no objects, or when all databases have exactly the same objects and all tables are added to replication sets. > [!NOTE] > > You can also use the `spock.replicate_ddl()` function to instruct Spock > to enable automatic DDL replication. Starting automatic DDL replication > with this function instructs Spock to check the statement type of each > transaction, and execute and replicate statements identified as DDL. > During the auto replication process, spock generates messages that provide information about the execution. Here are the descriptions for each message: - `DDL statement replicated.` This message is an INFO level message. It is displayed whenever a DDL statement is successfully replicated. To include these messages in the server log files, the configuration must have `log_min_messages=INFO` set. - `DDL statement replicated, but could be unsafe.` This message serves as a warning. It is generated when certain DDL statements, though successfully replicated, are deemed potentially unsafe. For example, statements like `CREATE TABLE... AS...` will trigger this warning. - `This DDL statement will not be replicated.` This warning message is generated when auto replication is active, but the specific DDL is either unsupported or intentionally excluded from replication. - `table 'test' was added to default replication set.` This is a LOG message providing information about the replication set used for a given table when `spock.include_ddl_repset` is set. --- [Upstream source](https://github.com/pgEdge/spock/blob/d05e2e2b6a82796d86e3c16ffb0d3fc38b1b329c/docs/managing/spock_autoddl.md) · `d05e2e2b6a82` · Copyright (c) 2021–2026, pgEdge, Inc.; portions Copyright the PostgreSQL Global Development Group and The Regents of the University of California. [PostgreSQL License](/docs/spock/upstream/about/license/). [PG.CENTER edition](https://github.com/pgsty/doc.pg.center/blob/4410c32dc9186a22859008303f474b72a779f583/content/pgedge/spock/managing/spock-autoddl.md) --- Backlinks: - [Configuration](/docs/spock/upstream/spock/configuration/) - [Getting started](/docs/spock/upstream/spock/getting-started/) - [Managing replication](/docs/spock/upstream/spock/managing/) - [Two-node tutorial](/docs/spock/upstream/spock/two-node/) ================ Source: https://mimus.pgsty.com/docs/spock/upstream/spock/managing/repset-trigger/index.md ================ # Automatically Assigning Tables to Replication Sets > Automatic DDL replication is a great alternative to using a trigger to manage replication sets, but if you do need to dynamically modify replication rules, column or row filters, or partition filters, this trigger might be useful. --- LLMS index: [llms.txt](/llms.txt) --- > The upstream Spock manual covers 6.0.0-beta.2 and includes 5.0 maintenance notes. For deployment, configuration and recovery on Mimus, use [Spock 5.0.15](/docs/spock/). Automatic DDL replication is a great alternative to using a trigger to manage replication sets, but if you do need to dynamically modify replication rules, column or row filters, or partition filters, this trigger might be useful. This trigger does not replicate the DDL statements across nodes, but automatically adds newly created tables to a replication set on the node on which the trigger fires. Before using the trigger, you should modify this trigger to account for all flavors of `CREATE TABLE` statements you might run. Since the trigger executes in a transaction, if the code in the trigger fails, the transaction is rolled back, including any `CREATE TABLE` statements that caused the trigger to fire. This means that statements like `CREATE UNLOGGED TABLE` will fail if the trigger fails. Please note that you must ensure that while using the trigger, automatic replication of DDL commands is disabled. You can use the following commands on the PSQL command line to disable automatic DDL updates: ```sql ALTER SYSTEM SET spock.enable_ddl_replication=off; ALTER SYSTEM SET spock.include_ddl_repset=off; ALTER SYSTEM SET spock.allow_ddl_from_functions=off; SELECT pg_reload_conf(); ``` You can use the event trigger facility to describe rules that define replication sets for newly created tables. For example: ```sql CREATE OR REPLACE FUNCTION spock_assign_repset() RETURNS event_trigger AS $$ DECLARE obj record; BEGIN FOR obj IN SELECT * FROM pg_event_trigger_ddl_commands() LOOP IF obj.object_type = 'table' THEN IF obj.schema_name = 'config' THEN PERFORM spock.repset_add_table('configuration', obj.objid); ELSIF NOT obj.in_extension THEN PERFORM spock.repset_add_table('default', obj.objid); END IF; END IF; END LOOP; END; $$ LANGUAGE plpgsql; CREATE EVENT TRIGGER spock_assign_repset_trg ON ddl_command_end WHEN TAG IN ('CREATE TABLE', 'CREATE TABLE AS') EXECUTE FUNCTION spock_assign_repset(); ``` The code snippet shown above adds any new table created in the `config` schema into a replication set named `configuration`, and adds all other new tables (which are not created by extensions) to the `default` replication set. --- [Upstream source](https://github.com/pgEdge/spock/blob/d05e2e2b6a82796d86e3c16ffb0d3fc38b1b329c/docs/managing/repset_trigger.md) · `d05e2e2b6a82` · Copyright (c) 2021–2026, pgEdge, Inc.; portions Copyright the PostgreSQL Global Development Group and The Regents of the University of California. [PostgreSQL License](/docs/spock/upstream/about/license/). [PG.CENTER edition](https://github.com/pgsty/doc.pg.center/blob/4410c32dc9186a22859008303f474b72a779f583/content/pgedge/spock/managing/repset-trigger.md) --- Backlinks: - [Managing replication](/docs/spock/upstream/spock/managing/) ================ Source: https://mimus.pgsty.com/docs/spock/upstream/spock/managing/filtering/index.md ================ # Filtering > Spock allows row based filtering on both the provider side and the subscriber side. --- LLMS index: [llms.txt](/llms.txt) --- > The upstream Spock manual covers 6.0.0-beta.2 and includes 5.0 maintenance notes. For deployment, configuration and recovery on Mimus, use [Spock 5.0.15](/docs/spock/). Spock allows row based filtering on both the provider side and the subscriber side. ## Row Filtering on the Provider {#row-filtering-on-the-provider} On the provider, you can implement row filtering with the `row_filter` property of the `spock.repset_add_table` function. The `row_filter` is a normal PostgreSQL expression with the same limitations as the `CHECK` constraint. A simple `row_filter` would look something like `row_filter := 'id > 0'`; this filter ensures that only rows where values of `id` column is greater than zero are replicated. You can use a volatile function inside `row_filter` but use caution with regard to `writes` as any expression that will do writes could potentially throw an error and stop replication. It's worth noting that the `row_filter` is running inside the replication session, so session specific expressions such as `CURRENT_USER` will have the values of the replication session and not the session that did the writes. ## Row Filtering on the Subscriber {#row-filtering-on-the-subscriber} On the subscriber, row-based filtering can be implemented using the standard `BEFORE TRIGGER` mechanism. You must mark triggers as either `ENABLE REPLICA` or `ENABLE ALWAYS` or they will not be executed by the replication process. --- [Upstream source](https://github.com/pgEdge/spock/blob/d05e2e2b6a82796d86e3c16ffb0d3fc38b1b329c/docs/managing/filtering.md) · `d05e2e2b6a82` · Copyright (c) 2021–2026, pgEdge, Inc.; portions Copyright the PostgreSQL Global Development Group and The Regents of the University of California. [PostgreSQL License](/docs/spock/upstream/about/license/). [PG.CENTER edition](https://github.com/pgsty/doc.pg.center/blob/4410c32dc9186a22859008303f474b72a779f583/content/pgedge/spock/managing/filtering.md) --- Backlinks: - [Managing replication](/docs/spock/upstream/spock/managing/) ================ Source: https://mimus.pgsty.com/docs/spock/upstream/spock/managing/partition-mgmt/index.md ================ # Replicating Partitioned Tables > By default, when you add a partitioned table to a Spock replication set, Spock will include all the current partitions of a partitioned table. --- LLMS index: [llms.txt](/llms.txt) --- > The upstream Spock manual covers 6.0.0-beta.2 and includes 5.0 maintenance notes. For deployment, configuration and recovery on Mimus, use [Spock 5.0.15](/docs/spock/). By default, when you add a partitioned table to a Spock replication set, Spock will include all the current partitions of a partitioned table. If you partition a table, or add partitions to a partitioned table at a later date, you will need to use the [`spock.repset_add_partition`](/docs/spock/upstream/spock/reference/functions/spock-repset-add-partition/) function to add them to your replication sets. The DDL for the partitioned table and partitions must reside on the subscriber nodes (like a non-partitioned table). When you remove a partitioned table from a replication set, by default, the partitions of the table will also be removed. You should use [`spock.repset_remove_partition`](/docs/spock/upstream/spock/reference/functions/spock-repset-remove-partition/) to update the cluster's meta-data. Replication of partitioned tables is a bit different from normal tables. During an initial synchronization, we query the partitioned table (or parent) to get all the rows for synchronization purposes and don't synchronize the individual partitions. After the initial sync of data, the normal operations resume and the partitions start replicating like normal tables. If you add individual partitions to a replication set, they will be replicated like regular tables (to the table of the same name as the partition on each subscriber). This has performance advantages if your partitioning definition is the same on both provider and subscriber, as the partitioning logic does not have to be executed with each sync. > [!NOTE] > > During the initial cluster setup and sync, table partitions are not > synced directly. Instead, the parent table is synced with the source > with data from all partitions, and the partitions are populated properly > on the destination preserving the table structure. This partitioning > behavior is equivalent to setting `synchronize_data = false` for > individual partitions during the initial sync. > > When setup completes (after the initial sync), both the parent table and > partitions are monitored for modifications, and changes are replicated > as they are made. > When partitions are replicated through a partitioned table, `TRUNCATE` commands always replicate to the complete list of affected tables or partitions. > [!NOTE] > > You can use a `row_filter` clause with a partitioned table, as well as > with individual partitions. --- [Upstream source](https://github.com/pgEdge/spock/blob/d05e2e2b6a82796d86e3c16ffb0d3fc38b1b329c/docs/managing/partition_mgmt.md) · `d05e2e2b6a82` · Copyright (c) 2021–2026, pgEdge, Inc.; portions Copyright the PostgreSQL Global Development Group and The Regents of the University of California. [PostgreSQL License](/docs/spock/upstream/about/license/). [PG.CENTER edition](https://github.com/pgsty/doc.pg.center/blob/4410c32dc9186a22859008303f474b72a779f583/content/pgedge/spock/managing/partition-mgmt.md) --- Backlinks: - [Managing replication](/docs/spock/upstream/spock/managing/) ================ Source: https://mimus.pgsty.com/docs/spock/upstream/spock/managing/lolor/index.md ================ # Using LOLOR to Manage Large objects > PostgreSQL's logical decoding facility does not support decoding changes to large objects; we recommend instead using the LOLOR extension to manage large objects. --- LLMS index: [llms.txt](/llms.txt) --- > The upstream Spock manual covers 6.0.0-beta.2 and includes 5.0 maintenance notes. For deployment, configuration and recovery on Mimus, use [Spock 5.0.15](/docs/spock/). PostgreSQL's logical decoding facility does not support decoding changes to [large objects](https://www.postgresql.org/docs/current/largeobjects.html); we recommend instead using the [LOLOR extension](https://github.com/pgEdge/lolor) to manage large objects. --- [Upstream source](https://github.com/pgEdge/spock/blob/d05e2e2b6a82796d86e3c16ffb0d3fc38b1b329c/docs/managing/lolor.md) · `d05e2e2b6a82` · Copyright (c) 2021–2026, pgEdge, Inc.; portions Copyright the PostgreSQL Global Development Group and The Regents of the University of California. [PostgreSQL License](/docs/spock/upstream/about/license/). [PG.CENTER edition](https://github.com/pgsty/doc.pg.center/blob/4410c32dc9186a22859008303f474b72a779f583/content/pgedge/spock/managing/lolor.md) --- Backlinks: - [Managing replication](/docs/spock/upstream/spock/managing/) ================ Source: https://mimus.pgsty.com/docs/spock/upstream/spock/managing/read-only/index.md ================ # Using Spock in Read-Only Mode > Spock supports operating a node in read-only mode. --- LLMS index: [llms.txt](/llms.txt) --- > The upstream Spock manual covers 6.0.0-beta.2 and includes 5.0 maintenance notes. For deployment, configuration and recovery on Mimus, use [Spock 5.0.15](/docs/spock/). Spock supports operating a node in read-only mode. Read-only status is managed using a GUC parameter named `spock.readonly`, which can be set to one of three values: | Value | Description | |---------|-------------| | `off` | No restrictions. All users may write. This is the default. | | `local` | Non-superuser local sessions are read-only. Replicated writes from apply workers are still permitted, so inbound replication continues normally. Superusers may still perform write operations. (The legacy alias `user` is accepted for backward compatibility.) | | `all` | Non-superuser local sessions and apply workers are blocked from writing. Superusers may still perform write operations. Use this mode when you need to stop both local application writes and inbound replication. | {.wide .expand} The setting is at cluster level: either all databases are read-only or all databases are read-write (the usual setting). Read-only mode is enforced by setting PostgreSQL's `transaction_read_only` flag for affected sessions. This means that any statement that would modify data — including DML (`INSERT`, `UPDATE`, `DELETE`), DDL, `TRUNCATE`, and DCL (`GRANT`, `REVOKE`) — will be rejected by PostgreSQL's standard read-only transaction checks. The databases are in read-only mode at the SQL level: however, the checkpointer, background writer, walwriter, and the autovacuum launcher are still running. This means that the database files are not read-only and that in some cases the database may still write to disk. ## Setting Read-Only Mode {#setting-read-only-mode} Only a superuser can modify the `spock.readonly` parameter. The value can be changed using the `ALTER SYSTEM` command: ```sql -- Block non-superuser local writes; inbound replication continues ALTER SYSTEM SET spock.readonly = 'local'; SELECT pg_reload_conf(); -- Block all non-superuser writes including replication ALTER SYSTEM SET spock.readonly = 'all'; SELECT pg_reload_conf(); -- Restore normal operation ALTER SYSTEM SET spock.readonly = 'off'; SELECT pg_reload_conf(); ``` To set the mode for the current session only: ```sql SET spock.readonly TO local; ``` To query the current status: ```sql SHOW spock.readonly; ``` ## Superuser writes and outbound replication {#superuser-writes-and-outbound-replication} In both `local` and `all` modes, superusers are exempt from the read-only restriction and may perform write operations. **The readonly setting has no effect on the walsender (outbound replication).** Any writes made by a superuser are captured in WAL and will be replicated outbound to other nodes in the cluster, regardless of the readonly mode. To perform repair operations that should **not** replicate to other nodes, use [`spock.repair_mode()`](/docs/spock/upstream/spock/reference/) to suppress outbound replication of DML/DDL statements: ```sql BEGIN; SELECT spock.repair_mode(true); -- Perform repair DML/DDL here... SELECT spock.repair_mode(false); COMMIT; ``` ## Behavior of `all` mode {#behavior-of-all-mode} In `all` mode, apply workers detect the setting and stop consuming inbound WAL — internally each worker raises a FATAL and exits, and the manager restarts it once read-only is cleared. When the mode is switched back to `off` or `local`, replication resumes from where it left off, **provided the upstream replication slot still retains the necessary WAL**. Plan for slot retention (`max_slot_wal_keep_size`, disk capacity) before placing a node in `all` mode for an extended period; if the upstream slot is recycled while the node is read-only, replication cannot resume from the prior position and the node will need to be re-synchronized. Notes: - Only superusers can set and unset the `spock.readonly` parameter. - By using a GUC parameter, you can easily manage the node's read-only status through standard PostgreSQL configuration mechanisms. --- [Upstream source](https://github.com/pgEdge/spock/blob/d05e2e2b6a82796d86e3c16ffb0d3fc38b1b329c/docs/managing/read_only.md) · `d05e2e2b6a82` · Copyright (c) 2021–2026, pgEdge, Inc.; portions Copyright the PostgreSQL Global Development Group and The Regents of the University of California. [PostgreSQL License](/docs/spock/upstream/about/license/). [PG.CENTER edition](https://github.com/pgsty/doc.pg.center/blob/4410c32dc9186a22859008303f474b72a779f583/content/pgedge/spock/managing/read-only.md) --- Backlinks: - [Managing replication](/docs/spock/upstream/spock/managing/) ================ Source: https://mimus.pgsty.com/docs/spock/upstream/spock/managing/snowflake/index.md ================ # Using Spock with Snowflake Sequences > The Snowflake extension provides a sequence-based unique ID solution to replace the Postgres built-in bigserial data type in distributed replication clusters. --- LLMS index: [llms.txt](/llms.txt) --- > The upstream Spock manual covers 6.0.0-beta.2 and includes 5.0 maintenance notes. For deployment, configuration and recovery on Mimus, use [Spock 5.0.15](/docs/spock/). The [Snowflake extension](https://github.com/pgEdge/snowflake-sequences) provides a sequence-based unique ID solution to replace the Postgres built-in `bigserial` data type in distributed replication clusters. Snowflake sequences minimize the risk of assigning an identical key value on different nodes at the same time; this prevents potential data conflicts. > [!NOTE] > > Spock strongly recommends using Snowflake sequences instead of > legacy Postgres sequences. Snowflake sequences alleviate concerns > that network lag could disrupt sequences in distributed > transactions. > Using a [`Snowflake` sequence](https://docs.pgedge.com/snowflake/v2-4/creating/) allows you to take full advantage of the benefits offered by a distributed, multi-master replication solution. Snowflake provides an `int8` and sequence-based unique ID solution to optionally replace the Postgres built-in `bigserial` data type. ## Comparing Sequence Types {#comparing-sequence-types} The following example compares the level of detail stored with a traditional Postgres sequence (`id` values `1` and `2`) versus the level of detail available with a Snowflake sequence (`id` values `135824181823537153` and `135824609030176769`): ```sql acctg=# SELECT id, snowflake.format(id), customer, invoice FROM orders; id | format | customer | invoice --------------------+-----------------------------------------------------------+------------------------+------------ 1 | {"id": 1, "ts": "2022-12-31 19:00:00-05", "count": 0} | Chesterfield Schools | art_9338 2 | {"id": 2, "ts": "2022-12-31 19:00:00-05", "count": 0} | Chesterfield Schools | math_9663 135824181823537153 | {"id": 1, "ts": "2024-01-10 14:16:48.438-05", "count": 0} | Prince William Schools | math_8330 135824609030176769 | {"id": 1, "ts": "2024-01-10 14:18:30.292-05", "count": 0} | Fluvanna Schools | art_9447 (4 rows) ``` > [!NOTE] Version of the example > The table preserves upstream output. With the v2.6.1 bit layout, the two larger IDs both encode node `0` and count `1`. [Snowflake functions](/docs/spock/upstream/snowflake/snowflake-functions/) ## Snowflake Sequence Structure {#snowflake-sequence-structure} Unlike Postgres sequences, a Snowflake sequence consists of a timestamp, a counter, and a unique node identifier; the structure ensures over 18 trillion unique sequence numbers. Snowflake sequences provide the following capabilities: - A Snowflake sequence lets you add or modify data in different regions while ensuring a unique transaction sequence. - A Snowflake sequence preserves unique transaction identifiers without manual administrative management of a numbering scheme. - A Snowflake sequence lets you compare ID generation times across nodes. Clock skew and the interval between ID generation and commit can affect the observed order. Internally, Snowflake sequences are 64-bit integers represented externally as `bigint` values. The 64 bits divide into the following bit fields: - Bit 63 is unused and represents the sign of `int8`. - Bits 22–62 store the timestamp with millisecond precision. - Bits 12–21 store the unique pgEdge Distributed Postgres node number. - Bits 0–11 store the counter within one millisecond. The timestamp is a 41-bit unsigned value representing millisecond precision with an epoch of 2023-01-01. The counter is a 12-bit unsigned value that increments per ID allocation; this provides 4096 unique IDs per millisecond, or 4 million IDs per second. The node number is a 10-bit unique identifier for the Postgres instance inside a global cluster; you set this value using the `snowflake.node` GUC in the `postgresql.conf` file. --- [Upstream source](https://github.com/pgEdge/spock/blob/d05e2e2b6a82796d86e3c16ffb0d3fc38b1b329c/docs/managing/snowflake.md) · `d05e2e2b6a82` · Copyright (c) 2021–2026, pgEdge, Inc.; portions Copyright the PostgreSQL Global Development Group and The Regents of the University of California. [PostgreSQL License](/docs/spock/upstream/about/license/). [PG.CENTER edition](https://github.com/pgsty/doc.pg.center/blob/4410c32dc9186a22859008303f474b72a779f583/content/pgedge/spock/managing/snowflake.md) --- Backlinks: - [Managing replication](/docs/spock/upstream/spock/managing/) ================ Source: https://mimus.pgsty.com/docs/spock/upstream/spock/modify/index.md ================ # Adding a Node to a Replicating Cluster > There are several tools and scripts you can use to add a node to a cluster; the way that you choose should depend on the use and state of your cluster: --- LLMS index: [llms.txt](/llms.txt) --- > The upstream Spock manual covers 6.0.0-beta.2 and includes 5.0 maintenance notes. For deployment, configuration and recovery on Mimus, use [Spock 5.0.15](/docs/spock/). There are several tools and scripts you can use to add a node to a cluster; the way that you choose should depend on the use and state of your cluster: * **Use Z0DAN to Add or Remove a Node with Zero Downtime** [Z0DAN](/docs/spock/upstream/spock/modify/zodan/) is a spock utility that provides scripts that you can use to seamlessly add or remove a node from your cluster with zero downtime. * **Use pgBackRest to Add a Node to a Replicating Cluster with Minimal Downtime** [pgBackRest](/docs/spock/upstream/spock/modify/add-node-pgbackrest/) is an open-source tool that you can use to add a node to a replicating cluster with minimal interruption. --- [Upstream source](https://github.com/pgEdge/spock/blob/d05e2e2b6a82796d86e3c16ffb0d3fc38b1b329c/docs/modify/index.md) · `d05e2e2b6a82` · Copyright (c) 2021–2026, pgEdge, Inc.; portions Copyright the PostgreSQL Global Development Group and The Regents of the University of California. [PostgreSQL License](/docs/spock/upstream/about/license/). [PG.CENTER edition](https://github.com/pgsty/doc.pg.center/blob/4410c32dc9186a22859008303f474b72a779f583/content/pgedge/spock/modify/_index.md) --- Section pages: - [Modifying a Cluster with Zodan](/docs/spock/upstream/spock/modify/zodan/): Zodan provides tools to add or remove a node with zero downtime. - [Adding a Node with pgBackRest](/docs/spock/upstream/spock/modify/add-node-pgbackrest/): You can use a pgBackRest backup to populate a new cluster node, and then add that node to your cluster with the Spock extension. - [Tutorial: Upgrading the Postgres Version In Place with pg_upgrade](/docs/spock/upstream/spock/modify/pg-upgrade-rolling-tutorial/): If your database is too large for your system's free storage to hold a second full copy, you can upgrade the node's existing data directory in place with pgupgrade. --- Backlinks: - [Tutorial: Upgrading the Postgres Version In Place with pg_upgrade](/docs/spock/upstream/spock/modify/pg-upgrade-rolling-tutorial/) ================ Source: https://mimus.pgsty.com/docs/spock/upstream/spock/modify/zodan/index.md ================ # Modifying a Cluster with Zodan > Zodan provides tools to add or remove a node with zero downtime. --- LLMS index: [llms.txt](/llms.txt) --- > The upstream Spock manual covers 6.0.0-beta.2 and includes 5.0 maintenance notes. For deployment, configuration and recovery on Mimus, use [Spock 5.0.15](/docs/spock/). Zodan provides tools to add or remove a node with zero downtime. The scripts are located in the [samples/Z0DAN](https://github.com/pgEdge/spock/tree/main/samples/Z0DAN) directory of the [Spock GitHub](https://github.com/pgEdge/spock) repository. During node addition, Zodan seamlessly manages creation of the new node, subscription management (both to and from the node), replication slot creation, data synchronization, replication slot advancement, and final activation of subscriptions. During node removal, Zodan simplifies removing fully-functional or failed nodes from a cluster. When you remove a node from a cluster, the removal does not delete Postgres artifacts (the database, data directory, log files, etc.). > [!NOTE] > > Zodan simplifies removing partially added nodes created during failed > node add operations. Additional cleanup steps may be required before > attempting another node deployment on the target host. > > [!NOTE] > > Each script must be run from the target node being added or removed. > ## Key Differences Between using Zodan and the Manual Process {#key-differences-between-using-zodan-and-the-manual-process} The following differences highlight how Zodan automates and simplifies node addition: - Zodan stores sync LSNs and uses them later to ensure subscriptions start from the correct point even if hours pass between steps. - Zodan automatically detects existing schemas on the new node and populates the `skip_schema` parameter, preventing conflicts during structure sync. - Zodan checks Spock versions before starting. Every node must be 5.0.9 or later, and the new node must run the same or a newer major.minor version than every existing node (patch levels may differ). So a 6.0.x node can join a 5.0.x cluster, and further 6.0.x nodes can join the resulting mixed cluster from any source node; a new node older than an existing node is rejected. - Zodan includes the `verify_subscription_replicating()` function after enabling subscriptions to ensure they reach replicating status. - When adding to a single-node cluster, Zodan handles the process differently — no disabled subscriptions are needed. - Zodan shows final status of all nodes and subscriptions across the entire cluster, not just the new node. For more information, review the following resources: - [Using Zodan](/docs/spock/upstream/spock/modify/zodan/zodan-readme/) - [Zodan Tutorial](/docs/spock/upstream/spock/modify/zodan/zodan-tutorial/) - [Zodan Scripts and Workflows](https://github.com/pgEdge/spock/tree/main/samples/Z0DAN) - [Spock Documentation](https://docs.pgedge.com/spock-v5/) --- [Upstream source](https://github.com/pgEdge/spock/blob/d05e2e2b6a82796d86e3c16ffb0d3fc38b1b329c/docs/modify/zodan/index.md) · `d05e2e2b6a82` · Copyright (c) 2021–2026, pgEdge, Inc.; portions Copyright the PostgreSQL Global Development Group and The Regents of the University of California. [PostgreSQL License](/docs/spock/upstream/about/license/). [PG.CENTER edition](https://github.com/pgsty/doc.pg.center/blob/4410c32dc9186a22859008303f474b72a779f583/content/pgedge/spock/modify/zodan/_index.md) --- Section pages: - [Tutorial: Adding a Node to a Cluster with Zero Downtime](/docs/spock/upstream/spock/modify/zodan/zodan-tutorial/): In this detailed walkthrough, we add a fourth node to a three-node cluster with zero downtime. - [Tutorial: Updating the Postgres Version with a Rolling Update](/docs/spock/upstream/spock/modify/zodan/zodan-rolling-pg-version-tutorial/): Zodan's addnode and removenode procedures move data between nodes regardless of which PostgreSQL major version each node runs. - [Zodan: Zero-Downtime Node Addition for Spock](/docs/spock/upstream/spock/modify/zodan/zodan-readme/): Zodan provides tools to add or remove a node with zero downtime. --- Backlinks: - [Changing the cluster](/docs/spock/upstream/spock/modify/) - [Tutorial: Updating the Postgres Version with a Rolling Update](/docs/spock/upstream/spock/modify/zodan/zodan-rolling-pg-version-tutorial/) - [Recovering from Catastrophic Node Failure](/docs/spock/upstream/spock/recovery/catastrophic-node-failure/) ================ Source: https://mimus.pgsty.com/docs/spock/upstream/spock/modify/zodan/zodan-tutorial/index.md ================ # Tutorial: Adding a Node to a Cluster with Zero Downtime > In this detailed walkthrough, we add a fourth node to a three-node cluster with zero downtime. --- LLMS index: [llms.txt](/llms.txt) --- > The upstream Spock manual covers 6.0.0-beta.2 and includes 5.0 maintenance notes. For deployment, configuration and recovery on Mimus, use [Spock 5.0.15](/docs/spock/). In this detailed walkthrough, we add a fourth node to a three-node cluster with zero downtime. In our example, the cluster nodes are `n1` (the source node), `n2`, `n3`, and the new node is `n4`. > [!WARNING] > > Important Prerequisites and Warnings > > - The new node should not be accessible to users while adding the node. > - Disable `auto_ddl` on all cluster nodes. > - Do not modify your DDL during node addition. > - The users must be identical on the source and target node. You must > create any users on the target node before proceeding; the > permissions must be identical for all users on both the source and > target nodes. > - The ZODAN process validates that all users from the source node exist > on the new node before proceeding with cluster addition. This > prevents replication failures caused by missing user permissions. > - The Spock configuration must be identical on both the source and the > target node. > - All nodes in your cluster must be available to Spock for the duration > of the node addition. > - The procedure should be performed on the new node being added. > - The `dblink` extension must be installed on the node from which > commands like `SELECT spock.add_node()` are being run. > - Prepare the new node to meet all of the prerequisites described here. > - If the process fails, do not immediately retry a command until you > ensure that all artifacts created by the workflow have been removed. > - The automated `spock.add_node()` procedure allows 180 seconds > (3 minutes) for each wait for a sync event between nodes. If > replication lag exceeds this window, the procedure will raise an > exception. Ensure network latency and replication lag are within > acceptable limits before starting, or raise the budget for the > session with > [`spock.sync_timeout`](/docs/spock/upstream/spock/configuration/#spocksync_timeout), as > described in [Setting the Synchronisation > Timeout](#setting-the-synchronisation-timeout) below. When following > the manual workflow below, you call `spock.wait_for_sync_event()` > directly and supply your own timeout (the examples use 1200 > seconds), so neither the default nor `spock.sync_timeout` applies. > ## Creating a Node Manually {#creating-a-node-manually} If you are not using `spock.node_create` to create the new node, you will need to complete the following steps: - Initialize the new node with `initdb`. - Create a database. - Create a database user. - Follow the instructions at the [GitHub repository](https://github.com/pgEdge/spock) to build and install Spock on the database. - Add `spock` to the `shared_preload_libraries` parameter in the `postgresql.conf` file. - Restart the server to update the configuration. - Use the `CREATE EXTENSION spock` command to create the Spock extension. ## Sample Configuration and New Node Creation Steps {#sample-configuration-and-new-node-creation-steps} In our example, the cluster configuration details include the following information: - Database: `inventory` - User: `pgedge` - Password: `1safepassword` - n1 (source): port 5432 - n2 (replica): port 5433 - n3 (replica): port 5434 - n4 (new node): port 5435 - Host: 127.0.0.1 The steps used to configure the new node (n4) include the following commands. The commands initialize the database and install Spock: ```bash # Initialize database initdb -D /path/to/data # Start Postgres pg_ctl -D /path/to/data start # Create database and user psql -c "CREATE DATABASE inventory;" psql -c "CREATE USER pgedge WITH PASSWORD '1safepassword';" psql -c "GRANT ALL ON DATABASE inventory TO pgedge;" # Install Spock extension psql -d inventory -c "CREATE EXTENSION spock;" psql -d inventory -c "CREATE EXTENSION dblink;" ``` ## Using the Zodan Procedure to Add a Node {#using-the-zodan-procedure-to-add-a-node} After creating the node, you can use [Zodan scripts](/docs/spock/upstream/spock/modify/zodan/zodan-readme/) to simplify adding a node to a cluster. To use the SQL script, connect to the new node that you wish to add to the pgEdge cluster. In the following example, the `psql` command connects to the new node: ```bash psql -h 127.0.0.1 -p 5435 -d inventory -U pgedge ``` Load the Zodan procedures with the following command: ```sql \i /path/to/zodan.sql ``` Then, use `spock.add_node()` from the new node to create the node definition. In the following example, the `spock.add_node` procedure adds node `n4` to the cluster: ```sql CALL spock.add_node( src_node_name := 'n1', src_dsn := 'host=127.0.0.1 dbname=inventory port=5432 user=pgedge password=1safepassword', new_node_name := 'n4', new_node_dsn := 'host=127.0.0.1 dbname=inventory port=5435 user=pgedge password=1safepassword', verb := true, new_node_location := 'Los Angeles', new_node_country := 'USA', new_node_info := '{"key": "value"}'::jsonb ); ``` The `spock.add_node` function executes the steps required to add a node to the cluster; a detailed explanation of the steps performed follows below. Should a problem occur during this process, you can source the `zodremove.sql` script and call the `spock.remove_node` procedure to remove the node or reverse partially completed steps. The `spock.remove_node` procedure should be called on the node being removed. ### Setting the Synchronisation Timeout {#setting-the-synchronisation-timeout} `spock.add_node()` waits at several points for the nodes to synchronise - for a sync event to arrive on a peer, for the new node to catch up, and for a subscription to start replicating. Each of those waits is allowed 180 seconds (3 minutes) by default, which is sized for a small cluster where a node joins in seconds. On a large database, catchup can legitimately take minutes or hours, and the procedure fails with a timeout long before the work is done. To raise the budget, set [`spock.sync_timeout`](/docs/spock/upstream/spock/configuration/#spocksync_timeout) in the same session, before calling the add_node procedure: ```sql SET spock.sync_timeout = '2h'; ``` The new value applies to every synchronisation wait the procedure performs, and it reverts when the session ends, so a long-running node addition does not need a cluster-wide configuration change. To raise the limit for every session, set the parameter in `postgresql.conf` instead. The setting bounds a whole wait, not an individual probe of a remote node; steps that also bound each remote probe - so that one unresponsive peer cannot consume the entire budget - keep their own, much smaller limit for that purpose. ## Manually Adding a Node to a Cluster {#manually-adding-a-node-to-a-cluster} The steps that follow outline the process Zodan goes through when adding a node. You can manually perform the same steps to add a node to a cluster instead of using `spock.add_node` above. ### Check the Spock Version Compatibility {#check-the-spock-version-compatibility} Before starting the node addition, verify that all nodes (n1, n2, n3, and n4) are running the exact same version of Spock. This prevents compatibility issues during replication setup. > [!NOTE] > > If any node has a different version, the process will abort with an > error. > On the orchestrator node, check the Spock version with the following commands: ```sql -- Check source node version SELECT version FROM dblink( 'host=127.0.0.1 dbname=inventory port=5432 user=pgedge password=1safepassword', 'SELECT extversion FROM pg_extension WHERE extname = ''spock''' ) AS t(version text); -- Expected: matches the version installed on every node in the cluster -- Check new node version SELECT version FROM dblink( 'host=127.0.0.1 dbname=inventory port=5435 user=pgedge password=1safepassword', 'SELECT extversion FROM pg_extension WHERE extname = ''spock''' ) AS t(version text); -- Expected: matches the version installed on every node in the cluster -- Check all existing cluster nodes (n2, n3) SELECT node_name, version FROM dblink( 'host=127.0.0.1 dbname=inventory port=5432 user=alice password=1safepassword', 'SELECT n.node_name, (SELECT extversion FROM pg_extension WHERE extname = ''spock'') as version FROM spock.node n' ) AS t(node_name text, version text); -- Expected output: every node reports the same Spock version, e.g. -- node_name | version -- -----------+---------- -- n1 | 5.0.6 -- n2 | 5.0.6 -- n3 | 5.0.6 ``` ### Validate Prerequisites {#validate-prerequisites} You should ensure that the new node is in good condition before adding the node to your replicating cluster. Perform safety checks to ensure node `n4` is a clean slate: - The n4 node must have the database and Spock extension installed. - The n4 node must have no user data or existing replication configuration. - Verify that a node named n4 does not already exist in the cluster. > [!NOTE] > > If any prerequisite fails, the process aborts to prevent conflicts. > #### Confirm that the Database Exists on n4 {#confirm-that-the-database-exists-on-n4} Try to connect to the database on n4. If this fails, the database does not exist and needs to be created first. In the following example, the query checks whether the database exists on n4: ```sql SELECT 1 FROM dblink( 'host=127.0.0.1 dbname=inventory port=5435 user=alice password=1safepassword', 'SELECT 1' ) AS t(dummy int); -- If no error, database exists ``` #### Confirm that n4 Has No User-Created Tables {#confirm-that-n4-has-no-user-created-tables} The new node must be empty; there can be no user tables in user schemas (system tables and extension tables are acceptable). If user tables exist, ZODAN will abort because syncing would overwrite existing data. In the following example, the query checks for user-created tables on n4: ```sql SELECT count(*) FROM dblink( 'host=127.0.0.1 dbname=inventory port=5435 user=alice password=1safepassword', 'SELECT count(*) FROM pg_tables WHERE schemaname NOT IN (''information_schema'', ''pg_catalog'', ''pg_toast'', ''spock'') AND schemaname NOT LIKE ''pg_temp_%'' AND schemaname NOT LIKE ''pg_toast_temp_%''' ) AS t(count integer); -- Expected: 0 ``` #### Confirm that n4 Does Not Exist in the Cluster {#confirm-that-n4-does-not-exist-in-the-cluster} Check if a node with the name n4 is already registered in the cluster. If the node exists, ZODAN aborts to prevent duplicate node names. The following example checks to see if n4 already exists in the cluster: ```sql -- On orchestrator node (connected to n1) SELECT count(*) FROM spock.node WHERE node_name = 'n4'; -- Expected: 0 ``` #### Confirm that n4 Contains No Subscriptions {#confirm-that-n4-contains-no-subscriptions} In the following example, the query checks whether n4 has any existing subscriptions: ```sql SELECT count(*) FROM spock.subscription s JOIN spock.node n ON s.sub_origin = n.node_id WHERE n.node_name = 'n4'; -- Expected: 0 ``` #### Confirm that n4 Contains No Replication Sets {#confirm-that-n4-contains-no-replication-sets} In the following example, the query checks whether n4 has any replication sets: ```sql SELECT count(*) FROM spock.replication_set rs JOIN spock.node n ON rs.set_nodeid = n.node_id WHERE n.node_name = 'n4'; -- Expected: 0 ``` ### Create a Replication Node on n4 {#create-a-replication-node-on-n4} After confirming the state of the new node, you can add the node to your cluster. In this step, you will create a Spock node object on n4: - This registers n4 as a participant in the replication cluster. - Think of this like giving n4 an ID badge that says "I'm part of this cluster now." > [!NOTE] > > After this step, n4 is visible in the `spock.node` table on all nodes. > #### Create a Node on n4 {#create-a-node-on-n4} Using `dblink`, connect to n4 and run `spock.node_create()` to register the node. The DSN tells other nodes how to connect to n4. In the following example, the `spock.node_create` function registers n4 as a cluster participant: ```sql -- Via dblink to n4 SELECT * FROM dblink( 'host=127.0.0.1 dbname=inventory port=5435 user=alice password=1safepassword', 'SELECT spock.node_create( node_name := ''n4'', dsn := ''host=127.0.0.1 dbname=inventory port=5435 user=alice password=1safepassword'', location := ''Los Angeles'', country := ''USA'', info := ''{\"key\": \"value\"}''::jsonb )' ) AS t(node_id oid); -- Expected output: -- node_id -- --------- -- 16389 ``` #### Confirm the Initial Node Count {#confirm-the-initial-node-count} In the following example, the query retrieves the current node count: ```sql SELECT count(*) FROM dblink( 'host=127.0.0.1 dbname=inventory port=5432 user=alice password=1safepassword', 'SELECT count(*) FROM spock.node' ) AS t(count integer); -- Expected: 4 (n1, n2, n3, n4) ``` ### Create Disabled Subscriptions and Slots {#create-disabled-subscriptions-and-slots} This is the critical bookmarking stage. During this stage, the process completes the following steps: - Create subscriptions from n2 to n4 and n3 to n4, but keep them disabled. - Before creating each subscription, trigger a `sync_event()` which returns an LSN (log sequence number). You can think of the LSN as a bookmark in the replication stream. - Save these bookmarks in a temporary table for later use. - When enabling these subscriptions later, transactions will start from exactly the right position. This ensures no data is missed or duplicated. - Subscriptions remain disabled because n4 should get all initial data from n1 (the source) in one clean sync. > [!NOTE] > > The n2 to n4 and n3 to n4 subscriptions are just being prepared now, > but will not start moving data until later. > #### Identify All Existing Nodes {#identify-all-existing-nodes} Query the cluster to find all of the nodes (n1, n2, n3, n4) and their connection strings. In the following example, the query retrieves all nodes and their DSNs: ```sql SELECT n.node_name, i.if_dsn FROM dblink( 'host=127.0.0.1 dbname=inventory port=5432 user=alice password=1safepassword', 'SELECT n.node_name, i.if_dsn FROM spock.node n JOIN spock.node_interface i ON n.node_id = i.if_nodeid' ) AS t(node_name text, if_dsn text); -- Expected output: -- node_name | if_dsn -- -----------+------------------------------------------------------------------ -- n1 | host=127.0.0.1 dbname=inventory port=5432 user=alice password=... -- n2 | host=127.0.0.1 dbname=inventory port=5433 user=alice password=... -- n3 | host=127.0.0.1 dbname=inventory port=5434 user=alice password=... -- n4 | host=127.0.0.1 dbname=inventory port=5435 user=alice password=... ``` #### For n2 to n4: Trigger Sync Event on n2 and Store LSN {#for-n2-to-n4-trigger-sync-event-on-n2-and-store-lsn} Call `sync_event()` on n2, which inserts a special marker into the n2 replication stream and returns the LSN where the marker was inserted. Store this LSN (0/1A7D1E0) in a temp table. Later, when enabling the sub_n2_n4 subscription, use this stored LSN to ensure the subscription starts from exactly this point, guaranteeing no data loss. In the following example, commands trigger a sync event and store the LSN: ```sql -- Trigger sync event on n2 SELECT * FROM dblink( 'host=127.0.0.1 dbname=inventory port=5433 user=alice password=1safepassword', 'SELECT spock.sync_event()' ) AS t(sync_lsn pg_lsn); -- Returns: 0/1A7D1E0 -- Store in temp table CREATE TEMP TABLE IF NOT EXISTS temp_sync_lsns ( origin_node text PRIMARY KEY, sync_lsn text NOT NULL ); INSERT INTO temp_sync_lsns (origin_node, sync_lsn) VALUES ('n2', '0/1A7D1E0') ON CONFLICT (origin_node) DO UPDATE SET sync_lsn = EXCLUDED.sync_lsn; ``` #### Create a Replication Slot on n2 {#create-a-replication-slot-on-n2} A replication slot is like a queue that holds all changes from n2 that need to be sent to n4. Even though the subscription is disabled, the slot starts collecting changes immediately. This ensures no data is lost between now and when the subscription is enabled. In the following example, the commands create a replication slot on n2: ```sql -- On n2 SELECT * FROM dblink( 'host=127.0.0.1 dbname=inventory port=5433 user=alice password=1safepassword', 'SELECT slot_name, lsn FROM pg_create_logical_replication_slot( ''spk_inventory_n2_sub_n2_n4'', ''spock_output'' )' ) AS t(slot_name text, lsn pg_lsn); -- Expected output: -- slot_name | lsn -- --------------------------+------------ -- spk_inventory_n2_sub_n2_n4 | 0/1A7D1E8 ``` #### Create Disabled Subscription on n4 from n2 {#create-disabled-subscription-on-n4-from-n2} We create the subscription object on n4, but with `enabled := false`. This tells n4 you will eventually subscribe to n2, but not yet. The subscription knows about the slot on n2 but is not actively pulling data yet. ```sql -- On n4 SELECT * FROM dblink( 'host=127.0.0.1 dbname=inventory port=5435 user=alice password=1safepassword', 'SELECT spock.sub_create( subscription_name := ''sub_n2_n4'', provider_dsn := ''host=127.0.0.1 dbname=inventory port=5433 user=alice password=1safepassword'', replication_sets := ARRAY[''default'', ''default_insert_only'', ''ddl_sql''], synchronize_structure := false, synchronize_data := false, forward_origins := ARRAY[]::text[], apply_delay := ''0''::interval, enabled := false, force_text_transfer := false, skip_schema := ARRAY[]::text[] )' ) AS t(subscription_id oid); ``` #### Repeat the Previous Steps for n3 to n4 {#repeat-the-previous-steps-for-n3-to-n4} In the following example, the commands perform the same operations for n3 to n4: ```sql -- Trigger sync event on n3 SELECT * FROM dblink( 'host=127.0.0.1 dbname=inventory port=5434 user=alice password=1safepassword', 'SELECT spock.sync_event()' ) AS t(sync_lsn pg_lsn); -- Returns: 0/1B8E2F0 -- Store LSN INSERT INTO temp_sync_lsns (origin_node, sync_lsn) VALUES ('n3', '0/1B8E2F0') ON CONFLICT (origin_node) DO UPDATE SET sync_lsn = EXCLUDED.sync_lsn; -- Create replication slot on n3 SELECT * FROM dblink( 'host=127.0.0.1 dbname=inventory port=5434 user=alice password=1safepassword', 'SELECT slot_name, lsn FROM pg_create_logical_replication_slot( ''spk_inventory_n3_sub_n3_n4'', ''spock_output'' )' ) AS t(slot_name text, lsn pg_lsn); -- Create disabled subscription on n4 from n3 SELECT * FROM dblink( 'host=127.0.0.1 dbname=inventory port=5435 user=alice password=1safepassword', 'SELECT spock.sub_create( subscription_name := ''sub_n3_n4'', provider_dsn := ''host=127.0.0.1 dbname=inventory port=5434 user=alice password=1safepassword'', replication_sets := ARRAY[''default'', ''default_insert_only'', ''ddl_sql''], synchronize_structure := false, synchronize_data := false, forward_origins := ARRAY[]::text[], apply_delay := ''0''::interval, enabled := false, force_text_transfer := false, skip_schema := ARRAY[]::text[] )' ) AS t(subscription_id oid); ``` ### Configure Cross-Node Replication {#configure-cross-node-replication} > [!NOTE] Edition note on slot ownership > A logical slot retains WAL on the node where it is created. The following historical examples connect to n2 and n3. Those slots retain changes on n2 and n3. Before allowing writes on n4, verify the slots on n4 that will serve its subscribers. The examples below do not establish that protection on n4. Now prepare for replication directing the data flow from n4 to the replica nodes (n2, n3): - Create replication slots on n2 and n3 that will hold changes from n4. - These slots will be used later when creating subscriptions for n2 and n3 to receive data from n4. - Create these slots early so they start buffering any changes from n4 immediately, even before the subscriptions are created. > [!NOTE] > > This prevents data loss if n4 receives writes during the setup process. > #### Create a Slot on n2 for a Future Subscription (sub_n4_n2) {#create-a-slot-on-n2-for-a-future-subscription-sub_n4_n2} Create a replication slot on n2 named `spk_inventory_n2_sub_n4_n2`. This slot will queue up changes from n4 that need to be sent to n2. The slot is ready, but there is no subscription using the slot yet; that comes later. In the following example, the command creates a replication slot on n2: ```sql SELECT * FROM dblink( 'host=127.0.0.1 dbname=inventory port=5433 user=alice password=1safepassword', 'SELECT slot_name, lsn FROM pg_create_logical_replication_slot( ''spk_inventory_n2_sub_n4_n2'', ''spock_output'' )' ) AS t(slot_name text, lsn pg_lsn); ``` #### Create a Slot on n3 for a Future Subscription (sub_n4_n3) {#create-a-slot-on-n3-for-a-future-subscription-sub_n4_n3} In the following example, the command creates a replication slot on n3: ```sql SELECT * FROM dblink( 'host=127.0.0.1 dbname=inventory port=5434 user=alice password=1safepassword', 'SELECT slot_name, lsn FROM pg_create_logical_replication_slot( ''spk_inventory_n3_sub_n4_n3'', ''spock_output'' )' ) AS t(slot_name text, lsn pg_lsn); ``` ### Trigger a Sync on Other Nodes, Wait on Source {#trigger-a-sync-on-other-nodes-wait-on-source} Before copying data from n1 to n4, ensure n1 has all the latest data from n2 and n3. - Any writes that happened on n2 or n3 must be fully replicated to n1 first. - For example, if a user inserted data on n2 one second ago, that data must be on n1 before copying n1's data to n4, or n4 would be missing that recent insert. - By triggering a sync event on n2 and waiting for the event on n1, you can confirm that n1 has received everything from n2 up to this exact moment. > [!NOTE] > > Process: Trigger `sync_event` on n2 (inserts a marker into the n2 > replication stream), wait on n1 for that marker to arrive, and repeat > for n3. > #### Sync n2 to n1 {#sync-n2-to-n1} Call the `sync_event()` function on n2, which returns an LSN (0/1C9F400). Then on n1, wait for that specific LSN to be replicated. When `wait_for_sync_event()` completes, you are guaranteed that n1 has received all changes from n2 up to and including that LSN. In the following example, the commands trigger a sync event and wait for completion: ```sql -- Trigger sync event on n2 SELECT * FROM dblink( 'host=127.0.0.1 dbname=inventory port=5433 user=alice password=1safepassword', 'SELECT spock.sync_event()' ) AS t(sync_lsn pg_lsn); -- Returns: 0/1C9F400 -- Wait for sync event on n1 SELECT * FROM dblink( 'host=127.0.0.1 dbname=inventory port=5432 user=alice password=1safepassword', 'CALL spock.wait_for_sync_event(true, ''n2'', ''0/1C9F400''::pg_lsn, 1200)' ) AS t(result bool); ``` #### Sync n3 to n1 {#sync-n3-to-n1} Perform the same process on n3. Trigger `sync_event()` on n3, get the LSN (0/1D0E510), and then wait for that LSN on n1. After both syncs complete, n1 is fully caught up with both n2 and n3. In the following example, the commands trigger a sync event on n3 and wait for completion on n1: ```sql -- Trigger sync event on n3 SELECT * FROM dblink( 'host=127.0.0.1 dbname=inventory port=5434 user=alice password=1safepassword', 'SELECT spock.sync_event()' ) AS t(sync_lsn pg_lsn); -- Returns: 0/1D0E510 -- Wait for sync event on n1 SELECT * FROM dblink( 'host=127.0.0.1 dbname=inventory port=5432 user=alice password=1safepassword', 'CALL spock.wait_for_sync_event(true, ''n3'', ''0/1D0E510''::pg_lsn, 1200)' ) AS t(result bool); ``` ### Copy the Source to New Subscription {#copy-the-source-to-new-subscription} This is the big data copy step. - Create an enabled subscription on n4 from n1 with `synchronize_structure=true` and `synchronize_data=true`. - This causes Spock to dump the entire schema (tables, indexes, constraints, etc.) from n1, restore that schema on n4, and copy all table data from n1 to n4. - Before creating the subscription, detect if n4 has any existing schemas that should be omitted from the sync (like monitoring tools, management schemas). Build a `skip_schema` array with these schema names. When Spock syncs the structure, Spock excludes these schemas using `pg_dump --exclude-schema`. When copying data, Spock also skips tables in these schemas. This prevents overwriting local tools or extensions on n4. > [!NOTE] > > This can take minutes to hours depending on database size (a 100GB > database might take 30+ minutes to sync). > #### Detect Existing Schemas on n4 {#detect-existing-schemas-on-n4} Query the n4 `information_schema` to find all user-created schemas (excluding system schemas like `pg_catalog`, `information_schema`, `spock`, `public`). If schemas like `mgmt_tools` or `monitoring` are found, they will be excluded from replication. In the following example, the query detects existing schemas on n4: ```sql SELECT string_agg(schema_name, ',') as schemas FROM dblink( 'host=127.0.0.1 dbname=inventory port=5435 user=alice password=1safepassword', 'SELECT schema_name FROM information_schema.schemata WHERE schema_name NOT IN (''information_schema'', ''pg_catalog'', ''pg_toast'', ''spock'', ''public'') AND schema_name NOT LIKE ''pg_temp_%'' AND schema_name NOT LIKE ''pg_toast_temp_%''' ) AS t(schema_name text); -- Returns: 'mgmt_tools,monitoring' (if any exist) ``` #### Create an Enabled Subscription on n4 from n1 {#create-an-enabled-subscription-on-n4-from-n1} Create a subscription (`sub_n1_n4`) on n4, pointing to n1 as the provider. The key parameters include: - `synchronize_structure := true` - Dump and restore schema from n1. - `synchronize_data := true` - Copy all table data from n1. - `enabled := true` - Start replicating immediately. - `skip_schema := ARRAY['mgmt_tools','monitoring']::text[]` - Exclude detected schemas. - `forward_origins := ARRAY[]::text[]` - Do not forward changes that originated elsewhere. What Spock does internally: - Run pg_dump on n1 with --exclude-schema=mgmt_tools --exclude-schema=monitoring - Restore dump on n4 - For each table in replication sets on n1: Skip tables in mgmt_tools and monitoring schemas → Run COPY command to transfer data from n1 to n4 - Once initial sync completes, start streaming ongoing changes from n1 to n4 ```sql -- Build skip_schema array based on detected schemas -- If schemas found: ARRAY['mgmt_tools','monitoring']::text[] -- If no schemas: ARRAY[]::text[] SELECT * FROM dblink( 'host=127.0.0.1 dbname=inventory port=5435 user=alice password=1safepassword', 'SELECT spock.sub_create( subscription_name := ''sub_n1_n4'', provider_dsn := ''host=127.0.0.1 dbname=inventory port=5432 user=alice password=1safepassword'', replication_sets := ARRAY[''default'', ''default_insert_only'', ''ddl_sql''], synchronize_structure := true, synchronize_data := true, forward_origins := ARRAY[]::text[], apply_delay := ''0''::interval, enabled := true, force_text_transfer := false, skip_schema := ARRAY[''mgmt_tools'',''monitoring'']::text[] )' ) AS t(subscription_id oid); ``` ### Trigger a Sync on the Source Node and Wait on the New Node {#trigger-a-sync-on-the-source-node-and-wait-on-the-new-node} After the initial bulk data copy, there might be a small lag to recover changes that happened on n1 while the copy was in progress. - This confirms that n4 has caught up completely with n1 before proceeding. - Trigger a `sync_event` on n1 (marking the current position in the n1 stream); then, wait on n4 for that marker to arrive. When the marker arrives, n4 has received and applied everything from n1 up to this point. > [!NOTE] > > For example: You start copying 100GB at 10:00 AM, but while copying, > users insert 1000 rows on n1 between 10:00-10:30. The copy completes > at 10:30, but those 1000 rows are still being streamed. You must wait > until all 1000 rows have been applied on n4 so you do not lose data. > #### Trigger a Sync Event on n1 {#trigger-a-sync-event-on-n1} Insert a sync marker into the n1 replication stream at the current position. The LSN returned (0/1E1F620) represents this exact moment in the n1 transaction log. In the following example, the command triggers a sync event on n1: ```sql SELECT * FROM dblink( 'host=127.0.0.1 dbname=inventory port=5432 user=alice password=1safepassword', 'SELECT spock.sync_event()' ) AS t(sync_lsn pg_lsn); -- Returns: 0/1E1F620 ``` #### Wait for Sync Event on n4 {#wait-for-sync-event-on-n4} On n4, wait for the sync marker that matches the returned LSN (0/1E1F620) to arrive and be processed. This is a blocking call; the call will not return until the n4 subscription from n1 has replicated up to this LSN. The timeout (1200 seconds = 20 minutes) is a value chosen for this manual example to give plenty of headroom; tune it to suit your environment. It prevents waiting forever if something goes wrong. (The automated `spock.add_node()` procedure uses a shorter 180-second internal timeout for its sync waits, as noted in the prerequisites.) In the following example, the command waits for the sync event on n4: ```sql SELECT * FROM dblink( 'host=127.0.0.1 dbname=inventory port=5435 user=alice password=1safepassword', 'CALL spock.wait_for_sync_event(true, ''n1'', ''0/1E1F620''::pg_lsn, 1200)' ) AS t(result bool); ``` ### Check the Commit Timestamp and Advance Slots {#check-the-commit-timestamp-and-advance-slots} This is a critical optimization step. Earlier, n4 received a full copy of all data from n1, which includes data that originally came from n2 and n3. Those nodes now have disabled subscriptions waiting to activate (sub_n2_n4 and sub_n3_n4). The replication slots on n2 and n3 have been buffering changes. > [!WARNING] > > If you enable those subscriptions now, n4 will receive duplicate > data (n4 already has n2's data via n1, then will get the data again > directly from n2). > Solution: Use the `lag_tracker` to find the exact timestamp when n4 last received data from n2 (even though the data came via n1). Then advance the n2 replication slot to skip past all data up to that timestamp. When enabling sub_n2_n4 later, the subscription only sends new changes that happened after the sync, not old data that n4 already has. > [!NOTE] > > Steps for each replica node: Check the n4 `lag_tracker` to get the > `commit_timestamp` for the last change from n2. On n2, convert that > timestamp to an LSN using `get_lsn_from_commit_ts()`. Then, advance > the n2 replication slot to that LSN. Repeat these steps for n3. > #### Get the Commit Timestamp for n2 to n4 {#get-the-commit-timestamp-for-n2-to-n4} Query the n4 `lag_tracker` table, which tracks replication progress to find the row where `origin_name='n2'` and `receiver_name='n4'`. The `commit_timestamp` tells us the last time n4 received a change that originated from n2. Even though the change came through n1, `lag_tracker` tracks the original source. In the following example, the query retrieves the commit timestamp: ```sql SELECT commit_timestamp FROM dblink( 'host=127.0.0.1 dbname=inventory port=5435 user=alice password=1safepassword', 'SELECT commit_timestamp FROM spock.lag_tracker WHERE origin_name = ''n2'' AND receiver_name = ''n4''' ) AS t(commit_timestamp timestamp); -- Returns: 2025-01-15 10:30:45.123456 ``` #### Advance the Slot on n2 {#advance-the-slot-on-n2} This is a two-step process: Use `spock.get_lsn_from_commit_ts()` to convert the timestamp (2025-01-15 10:30:45.123456) into an LSN that corresponds to that point in the n2 transaction log. Then, use `pg_replication_slot_advance()` to move the slot's `restart_lsn` forward to that position. The slot `spk_inventory_n2_sub_n2_n4` has been buffering all changes to n2. By advancing the slot, you discard everything up to this LSN (n4 already has the data). Now the slot only contains new changes that n4 needs. In the following example, the commands convert the timestamp and advance the slot: ```sql -- Get LSN from commit timestamp SELECT * FROM dblink( 'host=127.0.0.1 dbname=inventory port=5433 user=alice password=1safepassword', 'WITH lsn_cte AS ( SELECT spock.get_lsn_from_commit_ts( ''spk_inventory_n2_sub_n2_n4'', ''2025-01-15 10:30:45.123456''::timestamp ) AS lsn ) SELECT pg_replication_slot_advance(''spk_inventory_n2_sub_n2_n4'', lsn) FROM lsn_cte' ) AS t(slot_name name, end_lsn pg_lsn); ``` #### Repeat for n3 to n4 {#repeat-for-n3-to-n4} In the following example, the commands perform the same operations for n3 to n4: ```sql -- Get commit timestamp SELECT commit_timestamp FROM dblink( 'host=127.0.0.1 dbname=inventory port=5435 user=alice password=1safepassword', 'SELECT commit_timestamp FROM spock.lag_tracker WHERE origin_name = ''n3'' AND receiver_name = ''n4''' ) AS t(commit_timestamp timestamp); -- Returns: 2025-01-15 10:30:46.789012 -- Advance the slot on n3 SELECT * FROM dblink( 'host=127.0.0.1 dbname=inventory port=5434 user=alice password=1safepassword', 'WITH lsn_cte AS ( SELECT spock.get_lsn_from_commit_ts( ''spk_inventory_n3_sub_n3_n4'', ''2025-01-15 10:30:46.789012''::timestamp ) AS lsn ) SELECT pg_replication_slot_advance(''spk_inventory_n3_sub_n3_n4'', lsn) FROM lsn_cte' ) AS t(slot_name name, end_lsn pg_lsn); ``` ### Enable Disabled Subscriptions {#enable-disabled-subscriptions} In this step, activate subscriptions from replica nodes to new node using stored sync LSNs. > [!NOTE] > > Remember when you created disabled subscriptions and stored > sync LSNs? Now we bring it all together. Enable those subscriptions > (sub_n2_n4 and sub_n3_n4), and use the stored LSNs to verify they start > from the correct position. > Why the stored LSNs matter: When you created sub_n2_n4 and triggered `sync_event` on n2, you got LSN 0/1A7D1E0. That LSN marked the exact moment you created the replication slot. Between then and now, hours may have passed. The replication slot has been buffering changes, but you need to ensure the subscription starts processing from that original bookmark point, not skipping ahead. The verification: After enabling each subscription, call `wait_for_sync_event()` with the stored LSN. This confirms that the subscription has processed up to at least that sync point before you continue. After the slot advancement: The slots were advanced to skip duplicate data. Now when you enable the subscriptions, they will only send new changes that happened after the initial sync, which is exactly what you want. #### Enable sub_n2_n4 on n4 {#enable-sub_n2_n4-on-n4} Next, call `spock.sub_enable()` on n4 to activate the subscription. The subscription worker process starts, connects to n2, and begins pulling changes from the replication slot. The following example enables the subscription: ```sql -- Enable the subscription SELECT * FROM dblink( 'host=127.0.0.1 dbname=inventory port=5435 user=alice password=1safepassword', 'SELECT spock.sub_enable( subscription_name := ''sub_n2_n4'', immediate := true )' ) AS t(result bool); ``` #### Wait for Stored Sync Event from n2 {#wait-for-stored-sync-event-from-n2} Then, retrieve the LSN we stored (0/1A7D1E0) and use the LSN in the `wait_for_sync_event()` function. This is the key to the entire ZODAN approach. We are verifying that the subscription has caught up to the sync point we marked when we first set things up. This guarantees data consistency. In the following example, the query retrieves the stored LSN and waits for the sync event: ```sql -- Retrieve stored LSN SELECT sync_lsn FROM temp_sync_lsns WHERE origin_node = 'n2'; -- Returns: 0/1A7D1E0 -- Wait for that sync event on n4 SELECT * FROM dblink( 'host=127.0.0.1 dbname=inventory port=5435 user=alice password=1safepassword', 'CALL spock.wait_for_sync_event(true, ''n2'', ''0/1A7D1E0''::pg_lsn, 1200)' ) AS t(result bool); ``` #### Verify the Subscription is Replicating {#verify-the-subscription-is-replicating} Check the subscription status using the `sub_show_status()` function. We want to see `status='replicating'`, which means the subscription worker is active, connected to n2, and successfully applying changes. Any other status (down, initializing) would indicate a problem. The following example checks the subscription status on n4: ```sql -- Check subscription status on n4 SELECT subscription_name, status, provider_node FROM dblink( 'host=127.0.0.1 dbname=inventory port=5435 user=alice password=1safepassword', 'SELECT subscription_name, status, provider_node FROM spock.sub_show_status() WHERE subscription_name = ''sub_n2_n4''' ) AS t(subscription_name text, status text, provider_node text); -- Expected output: -- subscription_name | status | provider_node -- -------------------+-------------+--------------- -- sub_n2_n4 | replicating | n2 ``` #### Repeat the Steps for sub_n3_n4 {#repeat-the-steps-for-sub_n3_n4} In the following example, commands enable the subscription and verify replication: ```sql -- Enable subscription SELECT * FROM dblink( 'host=127.0.0.1 dbname=inventory port=5435 user=alice password=1safepassword', 'SELECT spock.sub_enable( subscription_name := ''sub_n3_n4'', immediate := true )' ) AS t(result bool); -- Retrieve stored LSN SELECT sync_lsn FROM temp_sync_lsns WHERE origin_node = 'n3'; -- Returns: 0/1B8E2F0 -- Wait for stored sync event SELECT * FROM dblink( 'host=127.0.0.1 dbname=inventory port=5435 user=alice password=1safepassword', 'CALL spock.wait_for_sync_event(true, ''n3'', ''0/1B8E2F0''::pg_lsn, 1200)' ) AS t(result bool); -- Verify status SELECT subscription_name, status, provider_node FROM dblink( 'host=127.0.0.1 dbname=inventory port=5435 user=alice password=1safepassword', 'SELECT subscription_name, status, provider_node FROM spock.sub_show_status() WHERE subscription_name = ''sub_n3_n4''' ) AS t(subscription_name text, status text, provider_node text); ``` ### Create Subscriptions from Other Nodes to New Node {#create-subscriptions-from-other-nodes-to-new-node} This step enables bidirectional replication from n4 to all other nodes. Up to this point, data has been flowing TO n4 from other nodes. Now we set up the reverse paths. Data will flow FROM n4 TO other nodes. We create subscriptions on n1, n2, and n3 that subscribe FROM n4. We waited until n4 was fully populated with data before allowing other nodes to subscribe to it. If we had created these subscriptions earlier, the other nodes would try to sync from an empty n4, which would cause problems. These subscriptions have `synchronize_structure=false` and `synchronize_data=false` because n1, n2, and n3 already have all the data. We only want them to receive NEW changes that happen ON n4 from now on, not copy existing data. After this, the cluster is fully bidirectional: - n1 sends to n4, n4 sends to n1 - n2 sends to n4, n4 sends to n2 - n3 sends to n4, n4 sends to n3 #### Create sub_n4_n1 on n1 {#create-sub_n4_n1-on-n1} Create a subscription *ON* n1 that *points TO* n4 as the provider. This is commonly misunderstood; the subscription is created on the RECEIVER node (n1), not the sender (n4). After this, any INSERT/UPDATE/DELETE that happens directly on n4 will replicate to n1. The following example creates the subscription: ```sql SELECT * FROM dblink( 'host=127.0.0.1 dbname=inventory port=5432 user=alice password=1safepassword', 'SELECT spock.sub_create( subscription_name := ''sub_n4_n1'', provider_dsn := ''host=127.0.0.1 dbname=inventory port=5435 user=alice password=1safepassword'', replication_sets := ARRAY[''default'', ''default_insert_only'', ''ddl_sql''], synchronize_structure := false, synchronize_data := false, forward_origins := ARRAY[]::text[], apply_delay := ''0''::interval, enabled := true, force_text_transfer := false, skip_schema := ARRAY[]::text[] )' ) AS t(subscription_id oid); ``` #### Create sub_n4_n2 on n2 {#create-sub_n4_n2-on-n2} This is the same concept. We create a subscription on n2 that pulls from n4. Now n2 will receive changes that happen on n4. In the following example, the command creates the subscription on n2: ```sql SELECT * FROM dblink( 'host=127.0.0.1 dbname=inventory port=5433 user=alice password=1safepassword', 'SELECT spock.sub_create( subscription_name := ''sub_n4_n2'', provider_dsn := ''host=127.0.0.1 dbname=inventory port=5435 user=alice password=1safepassword'', replication_sets := ARRAY[''default'', ''default_insert_only'', ''ddl_sql''], synchronize_structure := false, synchronize_data := false, forward_origins := ARRAY[]::text[], apply_delay := ''0''::interval, enabled := true, force_text_transfer := false, skip_schema := ARRAY[]::text[] )' ) AS t(subscription_id oid); ``` #### Create sub_n4_n3 on n3 {#create-sub_n4_n3-on-n3} The following command creates the subscription on n3: ```sql SELECT * FROM dblink( 'host=127.0.0.1 dbname=inventory port=5434 user=alice password=1safepassword', 'SELECT spock.sub_create( subscription_name := ''sub_n4_n3'', provider_dsn := ''host=127.0.0.1 dbname=inventory port=5435 user=alice password=1safepassword'', replication_sets := ARRAY[''default'', ''default_insert_only'', ''ddl_sql''], synchronize_structure := false, synchronize_data := false, forward_origins := ARRAY[]::text[], apply_delay := ''0''::interval, enabled := true, force_text_transfer := false, skip_schema := ARRAY[]::text[] )' ) AS t(subscription_id oid); ``` ### Monitor Replication Lag {#monitor-replication-lag} Next, we will verify that n4 is keeping up with n1. We monitor the lag_tracker table on n4 to ensure replication from n1 is keeping up. The lag_tracker shows the time difference between when a transaction was committed on n1 and when the transaction was applied on n4. If lag is growing (for example, 5 seconds, then 10 seconds, then 30 seconds), n4 cannot keep up with the write load from n1. This could indicate the following issues: - Network bandwidth issues. - n4 hardware is slower than n1. - Long-running transactions blocking replication. We want lag under 59 seconds, or lag_bytes=0 (meaning n4 has processed everything). If lag stays consistently low, n4 is successfully integrated. The following example monitors replication lag: ```sql -- Monitor lag from n1 → n4 on n4 DO $$ DECLARE lag_interval interval; lag_bytes bigint; BEGIN LOOP SELECT now() - commit_timestamp, replication_lag_bytes INTO lag_interval, lag_bytes FROM dblink( 'host=127.0.0.1 dbname=inventory port=5435 user=alice password=1safepassword', 'SELECT now() - commit_timestamp, replication_lag_bytes FROM spock.lag_tracker WHERE origin_name = ''n1'' AND receiver_name = ''n4''' ) AS t(lag_interval interval, lag_bytes bigint); RAISE NOTICE 'n1 → n4 lag: % (bytes: %)', COALESCE(lag_interval::text, 'NULL'), COALESCE(lag_bytes::text, 'NULL'); EXIT WHEN lag_interval IS NOT NULL AND (extract(epoch FROM lag_interval) < 59 OR lag_bytes = 0); PERFORM pg_sleep(1); END LOOP; RAISE NOTICE 'Replication lag monitoring complete'; END; $$; -- Expected output: -- NOTICE: n1 → n4 lag: 00:00:02.345 (bytes: 1024) -- NOTICE: n1 → n4 lag: 00:00:01.123 (bytes: 512) -- NOTICE: n1 → n4 lag: 00:00:00.456 (bytes: 0) -- NOTICE: Replication lag monitoring complete ``` ### Show All Nodes {#show-all-nodes} Next, we will verify that all of the nodes are registered; the following query displays all registered nodes: ```sql SELECT n.node_id, n.node_name, n.location, n.country, i.if_dsn FROM dblink( 'host=127.0.0.1 dbname=inventory port=5432 user=alice password=1safepassword', 'SELECT n.node_id, n.node_name, n.location, n.country, i.if_dsn FROM spock.node n JOIN spock.node_interface i ON n.node_id = i.if_nodeid ORDER BY n.node_name' ) AS t(node_id integer, node_name text, location text, country text, if_dsn text); -- Expected output: -- node_id | node_name | location | country | if_dsn -- ---------+-----------+-------------+---------+------------------------------------------------------------ -- 16385 | n1 | New York | USA | host=127.0.0.1 dbname=inventory port=5432 user=alice ... -- 16386 | n2 | Chicago | USA | host=127.0.0.1 dbname=inventory port=5433 user=alice ... -- 16387 | n3 | Boston | USA | host=127.0.0.1 dbname=inventory port=5434 user=alice ... -- 16389 | n4 | Los Angeles | USA | host=127.0.0.1 dbname=inventory port=5435 user=alice ... ``` ### Show the Status of all Subscriptions {#show-the-status-of-all-subscriptions} Next, we want to verify that all subscriptions are replicating. In the following example, the query displays subscription status across all nodes: ```sql -- Get subscriptions from all nodes SELECT node_name, subscription_name, status, provider_node FROM ( -- n1 subscriptions SELECT 'n1' as node_name, * FROM dblink( 'host=127.0.0.1 dbname=inventory port=5432 user=alice password=1safepassword', 'SELECT subscription_name, status, provider_node FROM spock.sub_show_status()' ) AS t(subscription_name text, status text, provider_node text) UNION ALL -- n2 subscriptions SELECT 'n2' as node_name, * FROM dblink( 'host=127.0.0.1 dbname=inventory port=5433 user=alice password=1safepassword', 'SELECT subscription_name, status, provider_node FROM spock.sub_show_status()' ) AS t(subscription_name text, status text, provider_node text) UNION ALL -- n3 subscriptions SELECT 'n3' as node_name, * FROM dblink( 'host=127.0.0.1 dbname=inventory port=5434 user=alice password=1safepassword', 'SELECT subscription_name, status, provider_node FROM spock.sub_show_status()' ) AS t(subscription_name text, status text, provider_node text) UNION ALL -- n4 subscriptions SELECT 'n4' as node_name, * FROM dblink( 'host=127.0.0.1 dbname=inventory port=5435 user=alice password=1safepassword', 'SELECT subscription_name, status, provider_node FROM spock.sub_show_status()' ) AS t(subscription_name text, status text, provider_node text) ) combined ORDER BY node_name, subscription_name; -- Expected output (12 rows): -- node_name | subscription_name | status | provider_node -- -----------+-------------------+-------------+--------------- -- n1 | sub_n2_n1 | replicating | n2 -- n1 | sub_n3_n1 | replicating | n3 -- n1 | sub_n4_n1 | replicating | n4 -- n2 | sub_n1_n2 | replicating | n1 -- n2 | sub_n3_n2 | replicating | n3 -- n2 | sub_n4_n2 | replicating | n4 -- n3 | sub_n1_n3 | replicating | n1 -- n3 | sub_n2_n3 | replicating | n2 -- n3 | sub_n4_n3 | replicating | n4 -- n4 | sub_n1_n4 | replicating | n1 -- n4 | sub_n2_n4 | replicating | n2 -- n4 | sub_n3_n4 | replicating | n3 ``` ### Verification {#verification} Next, we perform a series of tests to verify that the cluster is replicating between n1 and n4. First, we create a test table and insert data: ```sql -- On n1 CREATE TABLE test_replication (id serial primary key, data text, created_at timestamp default now()); INSERT INTO test_replication (data) VALUES ('Test from n1'); -- On n4 (wait a few seconds) SELECT * FROM test_replication; -- Expected: Row appears on n4 ``` ### Test Replication between n4 and n1 {#test-replication-between-n4-and-n1} Next, we insert data on n4: ```sql INSERT INTO test_replication (data) VALUES ('Test from n4'); ``` Then, verify replication on n1: ```sql -- On n1 (wait a few seconds) SELECT * FROM test_replication; -- Expected: Both rows appear on n1 ``` ### Our Final Cluster Topology {#our-final-cluster-topology} ``` ┌──────┐ │ n1 │ (source) └──┬───┘ ┌─────┼─────┬─────┐ │ │ │ │ ┌──▼──┐ │ ┌──▼──┐ ┌▼────┐ │ n2 │◄┼──┤ n3 │ │ n4 │ (new) └──┬──┘ │ └──┬──┘ └┬────┘ │ │ │ │ └────┴─────┴─────┘ ``` All nodes are now bidirectionally replicating: - n1, n2, n3, and n4 are all bidirectionally connected. - Total subscriptions: 12 (each node subscribes to 3 others). ## Troubleshooting {#troubleshooting} The following sections share commands that can help diagnose issues you encounter while adding a node: ### Subscription Status Stuck in 'initializing' or 'down' {#subscription-status-stuck-in-initializing-or-down} The following commands can help you identify places where a node is encountering issues with replication status: ```sql -- Check subscription status SELECT * FROM spock.sub_show_status(); -- Check table sync status SELECT * FROM spock.sub_show_table('sub_n2_n4', 'public.test_replication'); -- Check logs SELECT * FROM pg_stat_replication; ``` ### Node Addition Fails with a Timeout {#node-addition-fails-with-a-timeout} If `spock.add_node()` raises a timeout while waiting for a sync event or for the new node to catch up, the node is likely larger than the default 3-minute budget allows for. Remove the partially added node with `spock.remove_node`, then retry with a longer budget, as described in [Setting the Synchronisation Timeout](#setting-the-synchronisation-timeout): ```sql SET spock.sync_timeout = '2h'; ``` Use the lag query below to gauge how long catchup actually takes before choosing a value. ### Replication Lag Too High {#replication-lag-too-high} Use the following command to check replication lag on a subscribing node: ```sql -- Check lag on receiver node SELECT origin_name, receiver_name, now() - commit_timestamp as lag, replication_lag_bytes FROM spock.lag_tracker ORDER BY lag DESC; ``` ### Slot Not Advancing {#slot-not-advancing} Use the following command to check the status of a replication slot: ```sql -- Check slot status SELECT slot_name, slot_type, active, restart_lsn, confirmed_flush_lsn FROM pg_replication_slots WHERE slot_name LIKE 'spk_%'; ``` --- [Upstream source](https://github.com/pgEdge/spock/blob/d05e2e2b6a82796d86e3c16ffb0d3fc38b1b329c/docs/modify/zodan/zodan_tutorial.md) · `d05e2e2b6a82` · Copyright (c) 2021–2026, pgEdge, Inc.; portions Copyright the PostgreSQL Global Development Group and The Regents of the University of California. [PostgreSQL License](/docs/spock/upstream/about/license/). [PG.CENTER edition](https://github.com/pgsty/doc.pg.center/blob/4410c32dc9186a22859008303f474b72a779f583/content/pgedge/spock/modify/zodan/zodan-tutorial.md) --- Backlinks: - [Z0DAN](/docs/spock/upstream/spock/modify/zodan/) - [Tutorial: Updating the Postgres Version with a Rolling Update](/docs/spock/upstream/spock/modify/zodan/zodan-rolling-pg-version-tutorial/) - [Recovering from Catastrophic Node Failure](/docs/spock/upstream/spock/recovery/catastrophic-node-failure/) - [spock.sub_wait_for_sync](/docs/spock/upstream/spock/reference/functions/spock-sub-wait-for-sync/) - [spock.sync_event](/docs/spock/upstream/spock/reference/functions/spock-sync-event/) ================ Source: https://mimus.pgsty.com/docs/spock/upstream/spock/modify/zodan/zodan-rolling-pg-version-tutorial/index.md ================ # Tutorial: Updating the Postgres Version with a Rolling Update > Zodan's addnode and removenode procedures move data between nodes regardless of which PostgreSQL major version each node runs. --- LLMS index: [llms.txt](/llms.txt) --- > The upstream Spock manual covers 6.0.0-beta.2 and includes 5.0 maintenance notes. For deployment, configuration and recovery on Mimus, use [Spock 5.0.15](/docs/spock/). Zodan's `add_node` and `remove_node` procedures move data between nodes regardless of which PostgreSQL major version each node runs. Because of this, the same node-replacement strategy used to roll a Spock version forward also upgrades PostgreSQL itself. During the upgrade, you: - build a replacement node on the target PostgreSQL major version. - add it to the cluster. - confirm it is replicating. - remove the node it replaces. Since the replacement node is fully live and replicating before the node it replaces is removed, the cluster never drops below its optimal node count and the application sees no interruption - a true zero-downtime rolling upgrade of the PostgreSQL version. When a node also carries a physical standby for high availability, bootstrapping that standby and bringing it under Patroni folds into the same per-node loop, so high availability is preserved, before you move on to the next node. In this tutorial, a three-node cluster running PostgreSQL 16 (`n1`, `n2`, `n3`) rolls forward to PostgreSQL 18, becoming `n1b`, `n2b`, and `n3b` in turn. If you are also moving to a newer Spock version in the same rollout, the two upgrades combine in a single pass of add/verify/remove per node. > [!WARNING] > > Important Prerequisites and Warnings > > - Each replacement node should not be accessible to users while it > is being added. > - Disable automatic DDL replication on every node > (`spock.enable_ddl_replication = off`), and do not run DDL on the > cluster for the duration of the rollout. > - The users must be identical on the source and the replacement > node. Create any users on the replacement node before > proceeding; permissions must be identical for all users on both > the source and the replacement node. > - Zodan validates that all users from the source node exist on the > replacement node before proceeding. This prevents replication > failures caused by missing user permissions. > - All nodes in the cluster must be available to Spock for the > duration of each add/remove step. > - Run each `add_node` and `remove_node` call from the node being > added or removed. > - The `dblink` extension must be installed on the node from which > `add_node` or `remove_node` is called. > - On a node whose PostgreSQL build has the `output_plugin_libraries` > parameter (the patch versions in [Checking PostgreSQL Version > Compatibility Before Each > Step](#checking-postgresql-version-compatibility-before-each-step) > and later), it must list `spock_output`, or logical decoding with > Spock fails. On an older build the parameter does not exist and > must not be set. > - If a step fails partway, do not immediately retry. Confirm every > artifact the workflow created has been removed first, as > described in [Troubleshooting](#troubleshooting) below. > - `add_node` allows 180 seconds for each wait for a sync event > between nodes. If replication lag exceeds this window, the call > raises an exception. Confirm network latency and replication lag > are within acceptable limits before starting, or raise the > budget for the session with > [`spock.sync_timeout`](/docs/spock/upstream/spock/configuration/#spocksync_timeout). > - Do not remove an old node until its replacement reports > `replicating` status. > - Keep at least two nodes running at all times; never remove the > second-to-last old node and the first new node in the same > window. > - A rolling PostgreSQL update can only move a cluster forward. > Unlike a Spock version mismatch, Zodan does not check PostgreSQL > version ordering itself - see [Checking PostgreSQL Version > Compatibility Before Each > Step](#checking-postgresql-version-compatibility-before-each-step). > > [!NOTE] > > The examples run every instance on one host and use `127.0.0.1`. > When a node and its standby, or the nodes of the cluster, run on > separate hosts, use addresses each host can reach in connection > strings, `listen` and `connect_address`, and the etcd URLs, and > point every Patroni member of a scope at the same DCS. Replace the > `<...>` password placeholders with your own unique secrets. > ## Checking PostgreSQL Version Compatibility Before Each Step {#checking-postgresql-version-compatibility-before-each-step} Zodan's `check_spock_version_compatibility` procedure (invoked automatically by `add_node`) checks only the Spock extension version; it does not check the PostgreSQL server version. Before adding a replacement node, you can confirm its PostgreSQL patch version number yourself against the source node: ```sql SELECT * FROM dblink( 'host=127.0.0.1 dbname=inventory port=5432 user=pgedge password=', 'SHOW server_version_num' ) AS t(source_version int); SELECT * FROM dblink( 'host=127.0.0.1 dbname=inventory port=5442 user=pgedge password=', 'SHOW server_version_num' ) AS t(replacement_version int); ``` The replacement node's `server_version_num` must be the same as or greater than the source node's. The following table describes the first patch version of each PostgreSQL major version that has the `output_plugin_libraries` parameter. On those versions and later it must list `spock_output`; on earlier ones leave it unset: | PostgreSQL major version | Minimum patch version | |---|---| | 15 | 15.19 | | 16 | 16.15 | | 17 | 17.11 | | 18 | 18.6 | {.wide .expand} ## Preparing a Replacement Node {#preparing-a-replacement-node} Each replacement node needs its own host (or port, on a single host), data directory, and a PostgreSQL and Spock build at the target version, prepared before you call `add_node`. Add the pgEdge repository to the replacement node's host and install pgEdge Enterprise Postgres and Spock for the target version, as described in [Installing pgEdge Enterprise Postgres](/docs/spock/upstream/spock/getting-started/#install-pgedge-enterprise-postgres-recommended-path). For PostgreSQL 18 on RHEL, Rocky Linux, or AlmaLinux: ```bash sudo dnf install -y pgedge-postgres18-server pgedge-postgres18-contrib pgedge-spock50_18 ``` On Ubuntu or Debian: ```bash sudo apt install -y pgedge-postgresql-18 pgedge-postgresql-18-spock50 ``` In our example, the replacement node runs on its own port on the same host as the node it replaces; `n1b` runs on port `5442`. Initialize its data directory on the target PostgreSQL version: ```bash initdb -D /path/to/data/n1b --username=postgres ``` Before starting the replacement node for the first time, edit the `postgresql.conf` file: - set the settings Spock requires, as in [Configuring Spock](/docs/spock/upstream/spock/configuration/), using the source node's values. - size replication origin tracking for the target version. > [!NOTE] > > `shared_preload_libraries` only takes effect when the server > starts, so set it now rather than after `CREATE EXTENSION spock` > has already run. > PostgreSQL 15 through 17 track replication origins with the `max_replication_slots` parameter; PostgreSQL 18 and later uses the `max_active_replication_origins` parameter. Set the parameter to the number of subscriptions required: ```ini wal_level = logical max_worker_processes = 20 max_replication_slots = 10 max_wal_senders = 10 shared_preload_libraries = 'spock' track_commit_timestamp = on output_plugin_libraries = 'pgoutput, test_decoding, spock_output' # PostgreSQL 18 and later only: max_active_replication_origins = 10 ``` Copy any `spock.*` settings the existing nodes use, such as the conflict resolution settings, so the replacement behaves the same. Without `wal_level = logical`, `add_node` cannot create the slots it needs on the replacement, and it does not stop: it reports the failure only as a notice, and only when called with `verb := true`. Start Postgres on the replacement node's port, then connect with `psql` to confirm the settings took effect: ```bash pg_ctl -D /path/to/data/n1b -o "-p 5442" start ``` ```bash psql -p 5442 -c "SHOW shared_preload_libraries;" psql -p 5442 -c "SHOW output_plugin_libraries;" ``` Create the database and user, matching the source node exactly: ```bash psql -p 5442 -c "CREATE DATABASE inventory;" psql -p 5442 -c "CREATE USER pgedge WITH PASSWORD '';" psql -p 5442 -c "GRANT ALL ON DATABASE inventory TO pgedge;" ``` Install the Spock extension built against the target PostgreSQL version: ```bash psql -p 5442 -d inventory -c "CREATE EXTENSION spock;" psql -p 5442 -d inventory -c "CREATE EXTENSION dblink;" ``` If the node it replaces runs behind a physical standby for high availability, and the replacement node's target version is PostgreSQL 18 or later, also configure the server's native `sync_replication_slots` mechanism before adding it to the cluster - Spock's own failover worker does not run on PostgreSQL 18+. Both approaches below need a replication role, a known superuser password, and a `pg_hba.conf` entry permitting both to connect; set these up once, on the replacement node, before choosing a path: ```bash psql -p 5442 -c \ "CREATE ROLE replicator WITH REPLICATION LOGIN PASSWORD '';" psql -p 5442 -c "ALTER ROLE postgres WITH PASSWORD '';" ``` Add entries to `/path/to/data/n1b/pg_hba.conf` permitting the standby host to open a replication connection and, if you choose the Patroni path below, a superuser connection for Patroni's own health checks: ``` host replication replicator 127.0.0.1/32 md5 host all postgres 127.0.0.1/32 md5 ``` ```bash psql -p 5442 -c "SELECT pg_reload_conf();" ``` Choose one of the following approaches: - Manage the standby pair through Patroni, as described in step 3 of [Rolling the Update Across the Cluster](#rolling-the-update-across-the-cluster) below. - Configure the native path by hand: 1. Create a physical replication slot on the replacement node, for its future standby to stream through: ```sql SELECT pg_create_physical_replication_slot('n1b_standby_slot'); ``` 2. Take a base backup of the replacement node into the standby's data directory, streaming through that slot: ```bash pg_basebackup -h 127.0.0.1 -p 5442 -U replicator \ -D /path/to/data/n1b_standby -S n1b_standby_slot -X stream -P touch /path/to/data/n1b_standby/standby.signal ``` `standby.signal` is what makes the server start as a standby; `pg_basebackup -R` would also write it, but it would put a `primary_conninfo` without `dbname` into `postgresql.auto.conf`, which overrides the one set in the next steps, and slot sync needs `dbname`. 3. Set `synchronized_standby_slots` in the replacement node's `postgresql.conf`, naming that slot: ```ini synchronized_standby_slots = 'n1b_standby_slot' ``` 4. On the standby itself, point it at the replacement node and enable native slot sync in its `postgresql.conf`: ```ini sync_replication_slots = on primary_conninfo = 'host=127.0.0.1 port=5442 dbname=inventory user=replicator password=' primary_slot_name = 'n1b_standby_slot' hot_standby_feedback = on ``` 5. After starting the standby, confirm the slot synchronized: ```sql SELECT slot_name, synced, failover, invalidation_reason FROM pg_replication_slots WHERE NOT temporary; ``` See [Logical Slot Failover (HA Standby)](/docs/spock/upstream/spock/logical-slot-failover/) for the full reference, including the PostgreSQL 15/16 path and upgrading existing slots. ## Rolling the Update Across the Cluster {#rolling-the-update-across-the-cluster} Repeat the following four steps once per node, moving from `n1` to `n3` in our example. Finish all steps for one node before starting the next. 1. Connect to the prepared replacement node and load the Zodan workflow: ```sql \i /path/to/zodan.sql ``` > [!NOTE] > > Both `zodan.sql` and `zodremove.sql` are located in the > [samples/Z0DAN](https://github.com/pgEdge/spock/tree/main/samples/Z0DAN) > directory of the [Spock GitHub](https://github.com/pgEdge/spock) > repository. > Then add the replacement node, sourcing it from whichever node in the cluster is reachable and already caught up - the node you are replacing is the simplest choice for the first replacement: ```sql CALL spock.add_node( src_node_name := 'n1', src_dsn := 'host=127.0.0.1 dbname=inventory port=5432 user=pgedge password=', new_node_name := 'n1b', new_node_dsn := 'host=127.0.0.1 dbname=inventory port=5442 user=pgedge password=', verb := true, new_node_location := 'Los Angeles', new_node_country := 'USA', new_node_info := '{"role": "n1-replacement", "pg_version": "18"}'::jsonb ); ``` 2. Confirm the replacement node is fully caught up and replicating in both directions before touching the node it replaces: ```sql CALL spock.show_all_subscription_status( 'host=127.0.0.1 dbname=inventory port=5442 user=pgedge password=', true ); ``` Every subscription involving `n1b` should report `replicating`, including the subscriptions to and from `n2` and `n3` that `add_node` created automatically. 3. If the node being retired runs behind a physical standby for high availability, build a matching standby for `n1b` and bring the pair under Patroni, then cut over to it. Skip this step if the cluster does not use physical standbys. Patroni and a DCS (Distributed Configuration Store) must be installed and reachable from `n1b` and its future standby host before either node can run under Patroni. This tutorial uses `etcd` as the DCS, the most common choice for Patroni. Install Patroni on both hosts: ```bash pip install patroni[etcd] ``` This installs Patroni's etcd client library, not the etcd server itself. If no etcd cluster already serves the rest of your Spock cluster's Patroni pairs, install and start one. Package name and installation method vary by platform; see the [etcd releases page](https://github.com/etcd-io/etcd/releases) if your package manager does not provide one. A production etcd deployment needs an odd number of members (3 or 5) for quorum; the following configures a single-member etcd suitable for this tutorial: ```yaml # /etc/etcd/etcd.yml name: etcd0 data-dir: /path/to/data/etcd0 listen-client-urls: http://127.0.0.1:2379 advertise-client-urls: http://127.0.0.1:2379 listen-peer-urls: http://127.0.0.1:2380 initial-advertise-peer-urls: http://127.0.0.1:2380 initial-cluster: etcd0=http://127.0.0.1:2380 initial-cluster-token: n1b-etcd initial-cluster-state: new ``` ```bash etcd --config-file /etc/etcd/etcd.yml ``` Confirm `n1b` and its standby host can reach the DCS before continuing: ```bash etcdctl --endpoints=127.0.0.1:2379 endpoint health ``` Bring `n1b` under Patroni as the leader of a new Patroni cluster, rather than letting Patroni bootstrap it from scratch - `n1b` is already initialized and already running with the data `add_node` populated. Patroni only runs its bootstrap process against an empty `data_dir`, so pointing it at `n1b`'s existing, populated directory makes Patroni adopt the running instance as the cluster's first member instead: ```yaml scope: n1b-cluster namespace: /service/ name: n1b restapi: listen: 127.0.0.1:8541 connect_address: 127.0.0.1:8541 etcd3: hosts: 127.0.0.1:2379 postgresql: listen: 127.0.0.1:5442 connect_address: 127.0.0.1:5442 data_dir: /path/to/data/n1b bin_dir: /usr/pgsql-18/bin # /usr/lib/postgresql/18/bin on Ubuntu or Debian parameters: sync_replication_slots: on hot_standby_feedback: on callbacks: on_role_change: /path/to/set_synchronized_standby_slots.sh authentication: replication: username: replicator password: superuser: username: postgres password: ``` `sync_replication_slots` and `hot_standby_feedback` are the two settings the native slot sync path needs on a standby; set them on both `n1b` and `n1b_standby` rather than only on whichever is the standby today, since either one can end up in that role after a promotion. `synchronized_standby_slots` is deliberately left out of `postgresql.parameters` here - it is set directly on whichever node is primary, by the `on_role_change` callback below, and declaring it as a static Patroni-managed parameter would fight that callback: Patroni reconciles managed parameters back to the value in its own configuration, which would undo the callback's update after every promotion. Start Patroni against the running instance: ```bash patroni /path/to/n1b_patroni.yml ``` Then point a second Patroni instance at the same `scope` and DCS endpoint, under the member name `n1b_standby`, with an empty `data_dir`. Patroni finds the existing cluster in the DCS and, on first start, runs `pg_basebackup` itself against `n1b` to populate that empty directory - connecting as the `replicator` role over the replication connection permitted by the `pg_hba.conf` entry added above, using the credentials in the `authentication.replication` block below. No manual `pg_basebackup` step is needed on this path; Patroni's bootstrap process runs it for you: ```yaml scope: n1b-cluster namespace: /service/ name: n1b_standby restapi: listen: 127.0.0.1:8542 connect_address: 127.0.0.1:8542 etcd3: hosts: 127.0.0.1:2379 postgresql: listen: 127.0.0.1:5452 connect_address: 127.0.0.1:5452 data_dir: /path/to/data/n1b_standby bin_dir: /usr/pgsql-18/bin # /usr/lib/postgresql/18/bin on Ubuntu or Debian parameters: sync_replication_slots: on hot_standby_feedback: on callbacks: on_role_change: /path/to/set_synchronized_standby_slots.sh authentication: replication: username: replicator password: superuser: username: postgres password: ``` ```bash patroni /path/to/n1b_standby_patroni.yml ``` Confirm `n1b_standby` joined and is streaming before moving on: ```bash patronictl -c /path/to/n1b_patroni.yml list n1b-cluster ``` Also confirm, on `n1b`, that the slot backing the standby has synced before relying on it for failover: ```sql SELECT slot_name, synced, failover, invalidation_reason FROM pg_replication_slots WHERE NOT temporary; ``` `synchronized_standby_slots` names a Patroni-managed physical slot, and Patroni's auto-created slots are named after the member, not the role - the slot named `n1b_standby` only exists while `n1b_standby` is not the primary. The `on_role_change` callback named in both Patroni configurations above resets the setting on a future promotion to whichever member is then the standby. Patroni reads its local configuration only at start and on reload, so if you add the callback to a member that is already running, reload it afterwards: ```bash patronictl -c /path/to/n1b_patroni.yml reload n1b-cluster ``` The following script, deployed on `n1b` with `SIBLING_MEMBER` set to `n1b_standby` and `LOCAL_PORT` set to `5442` (and on `n1b_standby` with them set to `n1b` and `5452`), sets `synchronized_standby_slots` to the other member's name whenever this node becomes the primary: ```bash #!/bin/bash # Patroni on_role_change callback. # Patroni invokes this script as: #