您好,登錄后才能下訂單哦!
本節(jié)通過源碼解釋了snapshot中的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
免責(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)容。