pg_synthesize_wal
pg_synthesize_wal · Generate PostgreSQL WAL records of various sizes
Overview
| ID | Extension | Package | Version | Category | License | Language |
|---|---|---|---|---|---|---|
| 101097 | pg_synthesize_wal | pg_synthesize_wal | 1.0 | FEAT | PostgreSQL | C |
PostgreSQL · 15, 16, 17, 18
| Relationships | |
|---|---|
| Requires | pg_walinspect |
Usage
Sources:
pg_synthesize_wal deliberately writes custom WAL records with random or caller-supplied payloads. It is a developer, test, and sandbox tool for exercising WAL behavior—including records large enough to span WAL files—and is explicitly not recommended for production servers.
Enable and Generate WAL
The library must register its custom resource manager during postmaster startup. The control file also declares pg_walinspect as an extension dependency, although the implementation uses it only in tests.
Each overload returns the pg_lsn of the inserted record. The size overload generates random bytes; the text and bytea overloads preserve caller-supplied payload bytes in the custom record.
SQL Surface
pg_synthesize_wal_record(bigint)writes a random payload of the requested size.pg_synthesize_wal_record(text)writes a text payload.pg_synthesize_wal_record(bytea)writes a binary payload.
All overloads are strict and parallel-unsafe. The upstream supports PostgreSQL 15+, where custom WAL resource managers are available.
Safety Boundary
Calling these functions consumes WAL bandwidth, archive space, replication bandwidth, and recovery time; very large inputs may also consume substantial backend memory. Redo intentionally performs no data change, but the records still flow through WAL, archiving, replication, and recovery. Run only on disposable or capacity-controlled systems, monitor WAL growth and replica lag, and remove the preload setting before returning a cluster to normal service.