FULL AI ANALYSIS

PostgreSQL background writer and checkpoint IO spikes after increasing shared_buffers on primary

Generated Oct 3, 2026, 12:35:03 AM

Analysis summary

Increasing shared_buffers increases dirty shared buffer accumulation, which can cause more data to be written out during checkpoints if checkpoint-related settings (max_wal_size, checkpoint_timeout, bgwriter settings) are not tuned. With small max_wal_size and frequent timed checkpoints, larger buffers lead to heavier flush operations. The storage subsystem and its write cache behavior (battery-backed or write-back) also affect perceived latency. Balancing shared_buffers with checkpoint tuning and ensuring WAL sizing and bgwriter settings are appropriate reduces IO bursts.

Possible causes

Inadequate max_wal_size leading to forced checkpoints during buffer pressure

95%

Checkpoint frequency too high relative to max_wal_size causing full buffer flushes

80%

bgwriter settings (bgwriter_lru_maxpages, bgwriter_lru_multiplier) not scaled for larger shared_buffers

75%

Storage cache flushing behavior or controller battery/cache policy causing spikes when large flushes occur

70%

Suggested fixes

1

Diagnostic step 1

Increase max_wal_size (e.g., to 4–8GB) and adjust checkpoint_timeout to reduce forced checkpoint frequency. Make changes in postgresql.conf and reload/restart in maintenance window. Monitor pg_stat_bgwriter for checkpoint activity.

2

Diagnostic step 2

Tune bgwriter parameters: increase bgwriter_lru_maxpages and bgwriter_lru_multiplier so background writer spreads out writes. Test incrementally and monitor iostat/pg_stat_bgwriter.

3

Diagnostic step 3

Verify storage: check RAID controller cache policy (write-back with battery or capacitor), battery health, and firmware. If controller flushes are slow, involve storage admin; collect iostat with finer interval during checkpoint to correlate.

4

Diagnostic step 4

If immediate production impact persists, roll shared_buffers back incrementally (e.g., 8GB) as a temporary mitigation while tuning. For persistent storage performance problems, escalate to DBA/storage vendor with WAL and bgwriter stats and block device traces.