PostgreSQL中ReadBuffer_common函数
数据结构
BufferDesc
共享缓冲区的共享描述符(状态)数据
typedef struct BufferDesc
{
//buffer tag
BufferTag tag; /* ID of page contained in buffer */
//buffer索引编号(0开始)
int buf_id; /* buffer's index number (from 0) */
/* state of the tag, containing flags, refcount and usagecount */
//tag状态,包括flags/refcount和usagecount
pg_atomic_uint32 state;
//pin-count等待进程ID
int wait_backend_pid; /* backend PID of pin-count waiter */
//空闲链表链中下一个空闲的buffer
int freeNext; /* link in freelist chain */
//缓冲区内容锁
LWLock content_lock; /* to lock access to buffer contents */
} BufferDesc;
BufferTag
Buffer tag标记了buffer存储的是磁盘中哪个block
typedef struct buftag
{
//物理relation标识符
RelFileNode rnode; /* physical relation identifier */
ForkNumber fo

本文详细解析了PostgreSQL中的ReadBuffer_common函数,包括数据结构BufferDesc和BufferTag,函数流程解读,以及核心流程的简化说明。ReadBuffer_common首先进行变量初始化和判断,接着根据是否为临时表调用相应函数获取描述符。在缓存中未命中时,会通过存储管理器读取或扩展缓冲区。该过程涉及到并发控制和I/O操作,确保数据的正确性和一致性。
最低0.47元/天 解锁文章
605

被折叠的 条评论
为什么被折叠?



