Skip to content

Fix smgr_hook bypass in zeroextend and release - #1953

Open
tuhaihe wants to merge 1 commit into
apache:mainfrom
tuhaihe:fix-smgr-hook-bypass-zeroextend
Open

Fix smgr_hook bypass in zeroextend and release#1953
tuhaihe wants to merge 1 commit into
apache:mainfrom
tuhaihe:fix-smgr-hook-bypass-zeroextend

Conversation

@tuhaihe

@tuhaihe tuhaihe commented Sep 3, 2026

Copy link
Copy Markdown
Member

smgrrelease() and smgrzeroextend() dispatch through smgrsw[reln->smgr_which] instead of reln->smgr, so an f_smgr installed by smgr_hook is silently bypassed. Both arrived with the REL_16_9 merge in upstream form; every other entry point in smgr.c already goes through reln->smgr.

smgrrelease() is harmless for the in-tree managers. smgrzeroextend() is not: it is the bulk-extension path from ExtendBufferedRelShared(), and reaching mdzeroextend() unhooked makes register_dirty_segment() tag the checkpointer fsync request with the un-redirected path. That file never exists, so the next checkpoint PANICs with "could not fsync file ...: No such file or directory" and the segment enters a crash/restart loop.

Nothing changes when no hook is installed, since smgropen() sets reln->smgr to &smgrsw[reln->smgr_which].

Assisted-by: Claude Code

Fixes #ISSUE_Number

What does this PR do?

Type of Change

  • Bug fix (non-breaking change)
  • New feature (non-breaking change)
  • Breaking change (fix or feature with breaking changes)
  • Documentation update

Breaking Changes

Test Plan

  • Unit tests added/updated
  • Integration tests added/updated
  • Passed make installcheck
  • Passed make -C src/test installcheck-cbdb-parallel

Impact

Performance:

User-facing changes:

Dependencies:

Checklist

Additional Context

CI Skip Instructions


smgrrelease() and smgrzeroextend() dispatch through
smgrsw[reln->smgr_which] instead of reln->smgr, so an f_smgr installed
by smgr_hook is silently bypassed.  Both arrived with the REL_16_9
merge in upstream form; every other entry point in smgr.c already goes
through reln->smgr.

smgrrelease() is harmless for the in-tree managers.  smgrzeroextend()
is not: it is the bulk-extension path from ExtendBufferedRelShared(),
and reaching mdzeroextend() unhooked makes register_dirty_segment()
tag the checkpointer fsync request with the un-redirected path.  That
file never exists, so the next checkpoint PANICs with "could not fsync
file ...: No such file or directory" and the segment enters a
crash/restart loop.

Nothing changes when no hook is installed, since smgropen() sets
reln->smgr to &smgrsw[reln->smgr_which].

Assisted-by: Claude Code
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants