PostgreSQL Internals Deep Dive: From Startup to Crash Recovery, Physical Replication and Beyond
summary
Server startup runs pg_ctl -> DoStart -> StartPostmaster which forks and checks pg_control and the data directory, loads shared_preload_libraries via pg_init and registers background workers; child processes include checkpointer, bgwriter, WAL writer, autovacuum and new IO workers. Shared buffers use a clock-sweep eviction, max_usage_count=5 with ring buffers for bulk IO. WAL uses 16MB WAL segments and 8KB records, bgwriter flushes every 200ms bgwriter flush interval while checkpoints (default 5m) force full flush; crash recovery replays WAL from last checkpoint and replicas use base backup + libpq replication with a wal_sender/wal_receiver handshake.
AI-written summary · about
chapters (7)
- 0:00Introduction and agenda
- 0:51The engine starts
- 15:17Data and memory management
- 24:27Source of truth WAL
- 30:27Death and rebirth crash recovery
- 36:13Messy death and reaper
- 40:51Sharing is caring physical replication
related talks
24mPostgreSQL physical replication - internals, latest development and opportunities
50mParallel Recovery in PostgreSQL
43mPostgreSQL 17 and beyond
58mScaling Postgres
57mPostgreSQL When It's Not Your Job
48mPostgreSQL Replication: 20 Pitfalls and Solutions
31mPast, Present, and Future: Logical Decoding and Replication in PostgreSQL
