【0393】Postgres内核 checkpointer process ③ 构建 WAL records 工作缓存区

时间:2025-01-18 07:05:23

1. 初始化 ThisTimeLineIDRedoRecPtr

函数 InitXLOGAccess() 内部会初始化 ThisTimeLineID、wal_segment_size、doPageWrites 和 RedoRecPtr 等全局变量。

下面是这四个变量初始化前的值:

  • (gdb) p ThisTimeLineID
    $125 = 0
    (gdb) p wal_segment_size
    $126 = 16777216
    (gdb) p doPageWrites
    $127 = false
    (gdb) p RedoRecPtr
    $128 = 0

XlogCtl 变量成员初始化情况如下:

  • (gdb) p *XLogCtl
    $130 = {
    Insert = {
    insertpos_lck = 0 ‘\000’,
    CurrBytePos = 22421680,
    PrevBytePos = 22421624,
    pad = ‘\000’ <repeat