PostgreSQL DBA(24) - MVCC#4(快照中的xmax)
本节通过源码解释了snapshot中的xmax的具体含义.
一、xmax上一节提到PostgreSQL通过txid_current_snapshot()函数获取快照,格式为xmin : xmax : xip_list,其中xmax应理解为最后已完结事务(COMMITTED/ABORTED)的txid + 1。
详见以下PG源码:
SnapshotGetSnapshotData(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,最后已完结事务(COMMITTED/ABORTED)的txid + 1(ShmemVariableCache->latestCompletedXid + 1)。
二、参考资料PostgreSQL Source Code
声明:本站所有文章资源内容,如无特殊说明或标注,均为采集网络资源。如若本站内容侵犯了原著者的合法权益,可联系本站删除。