溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點擊 登錄注冊 即表示同意《億速云用戶服務(wù)條款》

PostgreSQL DBA(24) - MVCC#4(快照中的xmax)

發(fā)布時間:2020-08-10 10:07:57 來源:ITPUB博客 閱讀:199 作者:husthxd 欄目:關(guān)系型數(shù)據(jù)庫

本節(jié)通過源碼解釋了snapshot中的xmax的具體含義.

一、xmax

上一節(jié)提到PostgreSQL通過txid_current_snapshot()函數(shù)獲取快照,格式為xmin : xmax : xip_list,其中xmax應(yīng)理解為最后已完結(jié)事務(wù)(COMMITTED/ABORTED)的txid + 1。
詳見以下PG源碼:


Snapshot
GetSnapshotData(Snapshot snapshot)
{
    /* xmax is always latestCompletedXid + 1 */
    xmax = ShmemVariableCache->latestCompletedXid;
    Assert(TransactionIdIsNormal(xmax));
    TransactionIdAdvance(xmax);
    /* initialize xmin calculation with xmax */
    globalxmin = xmin = xmax;
    ...
    snapshot->xmax = xmax;
    ...
    return snapshot;
}

xmax is always latestCompletedXid + 1,最后已完結(jié)事務(wù)(COMMITTED/ABORTED)的txid + 1(ShmemVariableCache->latestCompletedXid + 1)。

二、參考資料

PostgreSQL Source Code

向AI問一下細節(jié)

免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點不代表本網(wǎng)站立場,如果涉及侵權(quán)請聯(lián)系站長郵箱:is@yisu.com進行舉報,并提供相關(guān)證據(jù),一經(jīng)查實,將立刻刪除涉嫌侵權(quán)內(nèi)容。

AI