Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: postgres/postgres
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: master
Choose a base ref
...
head repository: baotiao/postgres
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: master
Choose a head ref
Checking mergeability… Don’t worry, you can still create the pull request.
  • 4 commits
  • 12 files changed
  • 3 contributors

Commits on Feb 7, 2026

  1. Add double write buffer (DWB) for torn page protection

    Implement a double write buffer mechanism as an alternative to full page
    writes (FPW). When enabled, dirty pages are written to a dedicated DWB
    file before being written to the data files. This provides protection
    against torn pages without requiring full page images in WAL.
    
    Key benefits over FPW:
    - Dramatically reduced WAL volume (up to 98% reduction in IO-bound workloads)
    - Lower network bandwidth for replication
    - Faster WAL replay during recovery
    
    The implementation includes:
    - New GUC parameters: double_write_buffer (bool) and
      double_write_buffer_size (int, default 64MB)
    - DWB files stored in pg_dwbuf/ directory
    - Integration with checkpoint for proper flush ordering
    - Per-process file descriptor management for correctness
    
    Performance testing shows:
    - WAL reduction: 270GB -> 4.6GB (58x reduction) in IO-bound scenarios
    - TPS overhead: ~1% compared to no protection
    - Comparable TPS to FPW with vastly reduced WAL
    
    Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
    zongzhi.czz and claude committed Feb 7, 2026
    Configuration menu
    Copy the full SHA
    264a21d View commit details
    Browse the repository at this point in the history
  2. Fix DWB process handling and skip FPW when DWB enabled

    - Skip full page writes when double write buffer is enabled since DWB
      already provides torn page protection
    - Fix file descriptor handling after fork by tracking process ID
    - Initialize DWB in checkpointer process
    - Improve batch synchronization in DWBufPostCheckpoint
    - Add DWB shared memory initialization in ipci.c
    
    Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
    zongzhi.czz and claude committed Feb 7, 2026
    Configuration menu
    Copy the full SHA
    83100d9 View commit details
    Browse the repository at this point in the history
  3. Add Claude Code configuration

    Add local settings for Claude Code with permission allowlist for
    common development and testing commands.
    
    Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
    zongzhi.czz and claude committed Feb 7, 2026
    Configuration menu
    Copy the full SHA
    c6d8f95 View commit details
    Browse the repository at this point in the history
  4. Fix critical correctness bugs in double write buffer (DWB)

    Fix several issues that made the DWB feature unsafe:
    
    1. CRC computation: Move crc to first field of DWBufPageSlot and zero
       it before computing, so the stale crc value is excluded from the
       CRC range. Previously verification would always fail.
    
    2. Fsync before data file writes: DWB pages must be durable before
       data file writes begin. Add per-page DWBufFlushFile() for
       non-checkpoint writes (bgwriter/backend eviction), and batch
       DWBufFlush() in BufferSync for checkpoint writes.
    
    3. Checkpoint integration: Wire up DWBufPreCheckpoint/PostCheckpoint
       calls in CreateCheckPoint and CreateRestartPoint — they existed
       but were never called.
    
    4. Recovery path: Wire up DWBufRecoveryInit in StartupXLOG to build
       recovery hash, DWBufRecoverPage in buffer_readv_complete to
       recover torn pages, and DWBufRecoveryFinish after FinishWalRecovery.
    
    5. Backup FPW: Keep full_page_writes enabled when a backup is running
       even with DWB on, since pg_basebackup doesn't copy DWB files.
    
    6. Slot overflow: Add bounds check when write_pos >= num_slots,
       flush and wrap instead of overwriting valid data.
    
    7. PostCheckpoint race: Add resetting flag to prevent concurrent
       DWBufWritePage calls during position reset.
    
    8. Build/initdb: Add dwbuf.c to meson.build, pg_dwbuf to initdb
       subdirs array.
    
    9. Minor: Remove unused old_batch_id, fix %ld format string cast.
    
    Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
    baotiao and claude committed Feb 7, 2026
    Configuration menu
    Copy the full SHA
    59e2758 View commit details
    Browse the repository at this point in the history
Loading