Skip to content

Buffer locking is special (hints, checksums, AIO writes) #167

@grantzhou

Description

@grantzhou

--- As of 2026-02-10T16:49:36.000Z ---

Antonin Houska reported an issue where HeapTupleSatisfiesMVCCBatch() is incorrectly called during logical decoding with historic MVCC snapshots, causing problems with REPACK operations. The root cause is that the IsMVCCSnapshot macro includes both regular and historic MVCC snapshots, but page-at-a-time scans should only work with regular MVCC snapshots. During logical decoding, this leads to incorrect hint bit setting on pg_class entries, resulting in "cache lookup failed for relation" errors.

Andres Freund confirmed this is unintentional behavior and proposed restricting page-at-a-time scans to exclude historic snapshots by modifying the condition to disable pagemode for historic MVCC snapshots. Houska tested the fix and confirmed it resolves the issue. For a proper solution, Freund suggests splitting IsMVCCSnapshot into separate functions: IsMVCCSnapshot() for regular snapshots only, and IsMVCCLikeSnapshot() for both types, then reviewing all existing callers.

Antonin Houska报告了一个问题,HeapTupleSatisfiesMVCCBatch()在逻辑解码过程中被错误地调用,使用了历史MVCC快照,导致REPACK操作出现问题。根本原因是IsMVCCSnapshot宏包括常规和历史MVCC快照,但按页扫描应该只适用于常规MVCC快照。在逻辑解码期间,这会导致pg_class条目上的提示位设置不正确,产生"cache lookup failed for relation"错误。

Andres Freund确认这是非预期行为,提议通过修改条件来限制按页扫描,对历史MVCC快照禁用页面模式。Houska测试了修复方案并确认解决了问题。为了得到合适的解决方案,Freund建议将IsMVCCSnapshot拆分为单独的函数:IsMVCCSnapshot()仅用于常规快照,IsMVCCLikeSnapshot()用于两种类型,然后审查所有现有调用者。

participants - 参与者:

Metadata

Metadata

Assignees

No one assigned

    Labels

    hacker discussionshacker discussions summarized by PGNexus Agent

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions