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: postgresql-cfbot/postgresql
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: cf/6319~1
Choose a base ref
...
head repository: postgresql-cfbot/postgresql
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: cf/6319
Choose a head ref
  • 2 commits
  • 2 files changed
  • 2 contributors

Commits on Dec 25, 2025

  1. Fix 'unexpected data beyond EOF' on replica restart

    On restart, a replica can fail with an 'unexpected data beyond EOF in
    block 200 of relation T/D/R' error. This can happen under the following
    circumstances:
    
    - A relation has a size of 400 blocks.
      - Blocks 201 to 400 are empty.
      - Block 200 has two rows.
      - Blocks 100 to 199 are empty.
    - A restartpoint is done
    - Vacuum truncates the relation to 200 blocks
    - A FPW deletes a row in block 200
    - A checkpoint is done
    - A FPW deletes the last row in block 200
    - Vacuum truncates the relation to 100 blocks
    - The replica restarts
    
    When the replica restarts:
    - The relation on disk is reduced to 100 blocks due to having applied
      the truncate before restart.
    - The first truncate to 200 blocks is replayed. It silently fails, but
      it will still update the cache size to 200 blocks
    - The first FPW on block 200 is applied, XLogReadBufferForRead will rely
      on the cached size and incorrectly assume the page exists in file,
      and thus won't extend the relation.
    - The Checkpoint Online is replayed, calling smgrdestroyall which will
      discard the cached size.
    - The second FPW on block 200 is applied. This time, the detected size
      is 100 blocks, an extend is attempted. However, the block 200 is
      already present in the buffer table due to the first FPW. This
      triggers the 'unexpected data beyond EOF' since the page isn't new.
    
    This patch fixes the issue by only updating smgr_cached_nblocks when
    the truncated size is smaller. When the truncated size is higher, the
    file isn't modified and we restore the old cached value.
    bonnefoa authored and Commitfest Bot committed Dec 25, 2025
    Configuration menu
    Copy the full SHA
    b95feb7 View commit details
    Browse the repository at this point in the history
  2. [CF 6319] v4 - Fix possible 'unexpected data beyond EOF' on replica r…

    …estart
    
    This branch was automatically generated by a robot using patches from an
    email thread registered at:
    
    https://commitfest.postgresql.org/patch/6319
    
    The branch will be overwritten each time a new patch version is posted to
    the thread, and also periodically to check for bitrot caused by changes
    on the master branch.
    
    Patch(es): https://www.postgresql.org/message-id/CAO6_XqrK-rpYnSfXP+sf=DdQR6ugO_p2W6Sw6XetmtqokeK3uA@mail.gmail.com
    Author(s): Anthonin Bonnefoy
    Commitfest Bot committed Dec 25, 2025
    Configuration menu
    Copy the full SHA
    9412996 View commit details
    Browse the repository at this point in the history
Loading