← ClaudeAtlas

multixactlisted

PostgreSQL's MultiXact machinery — `src/backend/access/transam/multixact.c` — the multi-transaction ID system that lets a single heap tuple record multiple concurrent lockers (for `SELECT ... FOR SHARE` and `SELECT ... FOR UPDATE` blends) plus the multixact-freeze / wraparound path. Loads when the user asks about MultiXactId semantics, `xmax` interpretation with the `HEAP_XMAX_IS_MULTI` bit, why a tuple can appear to be locked by multiple transactions, tuple-locking modes (`FOR SHARE` / `FOR NO KEY UPDATE` / `FOR KEY SHARE`), the multixact SLRU (`pg_multixact/`), MultiXact member offsets, or the `autovacuum_multixact_freeze_max_age` wraparound path. Skip when the ask is about clog (regular transaction commit status — sibling but different code) or 2PC prepared transactions.
matejformanek/postgres-claude · ★ 0 · AI & Automation · score 70
Install: claude install-skill matejformanek/postgres-claude
# multixact — multi-transaction IDs for tuple locking Every heap tuple has an `xmax` field. In the simple case, `xmax` is the XID of a transaction that either deleted or exclusively locked the tuple. But PG supports **multiple concurrent lockers** on the same tuple (row-level shared locks + key-share locks + non-blocking-with-updates), which requires representing "this tuple is currently locked by transactions A, B, and C" in a fixed-size field. The solution: when a tuple has multiple lockers, `xmax` holds a **MultiXactId** and the `HEAP_XMAX_IS_MULTI` infomask bit is set. The MultiXact ID is a handle into a separate lookup table (`pg_multixact/`) that maps to the set of member XIDs + their per-member lock strength. ## The file map | File | Lines | Role | |---|---:|---| | `access/transam/multixact.c` | 95K | **The single file for all things MultiXact.** SLRU management, ID allocation, member lookup, freezing, wraparound. | | `access/transam/subtrans.c` | 13K | Not multixact but often confused — subtransaction xid → parent xid mapping. Same SLRU pattern, different purpose. | | `access/transam/clog.c` | 37K | Also not multixact but often confused — regular transaction commit status. Same SLRU pattern, different purpose. | MultiXact lives on-disk in **two SLRU segments**: - `pg_multixact/offsets/` — one entry per MultiXactId, giving the offset into `members/` for that multixact's member list. - `pg_multixact/members/` — variable-length arrays; each entry is `(xid, Transact