← ClaudeAtlas

wal-and-xloglisted

Add or modify a PostgreSQL WAL / XLOG record — covers choosing built-in rmgr vs Generic WAL (generic_xlog.c) vs custom rmgr (RegisterCustomRmgr), the XLogInsert + XLogRegisterBuffer idiom, writing a correct redo function, FPI / hint-bit (MarkBufferDirtyHint) rules, full-page-write handling, updating rmgrdesc + pg_waldump output, and bumping XLOG_PAGE_MAGIC when format changes. Use whenever a PG patch emits XLogInsert, adds an access method that needs durability, writes or modifies a redo function, registers a custom rmgr via RegisterCustomRmgr, or reviews a patch that changes WAL-record formats. Skip for MySQL binlog / GTID / row-based logging, SQLite WAL journal mode, Kafka log compaction / segment retention, pgbackrest / barman / wal-g operational config, recovery.conf / standby.signal DBA-side configuration, and generic write-ahead-logging theory or ARIES algorithm questions.
matejformanek/postgres-claude · ★ 0 · Code & Development · score 70
Install: claude install-skill matejformanek/postgres-claude
# WAL & XLOG — operational skill This is the procedural cookbook. For the conceptual model (LSNs, FPI, checkpoints, rmgrs) read `knowledge/architecture/wal.md` first. ## When to use what | Situation | Use | |---|---| | In-tree access method, new record type | new builtin rmgr (RmgrId < 128) — needs core patch | | Extension that just modifies pages (small new index AM, prototype) | **Generic WAL** (`generic_xlog.c`) | | Extension that needs compact records, logical decoding, or custom replay logic | **Custom rmgr** via `RegisterCustomRmgr` | | Optimisation hint that can be re-derived from authoritative state | **no WAL** — use `MarkBufferDirtyHint()` | | Tracking commit/abort of an XID (you almost never need to do this) | not a WAL concern — it's pg_xact | [from-comment `source/src/backend/access/transam/rmgr.c:97-104`; from-code `source/src/backend/access/transam/generic_xlog.c:1-12`] ## Custom rmgr vs Generic WAL — decision Choose **Generic WAL** when: - You're prototyping or your extension is small. - Record volume isn't a bottleneck (per-page delta can be larger than a hand-rolled record). - You don't need logical decoding. Choose **Custom rmgr** when: - Record volume matters (frequent small changes). - You need replay-time semantics beyond "apply this page delta" (e.g. cross-page invariants, structure-specific recovery). - You need a `rm_decode` hook for logical decoding. - You want pretty `pg_waldump` output via `rm_desc` / `rm_identify`. ## Custom rmgr — ful