cause only
* during or after acquiring a shared lockcould an XID possibly become a
* member of a MultiXact, and that MultiXactwould have to be created
* during or after the lock acquisition.)
*
* OldestVisibleMXactId[k] is the oldestMultiXactId each backend's
* current transaction(s) think is potentiallylive, or InvalidMultiXactId
* when not in a transaction or not in atransaction that's paid any
* attention to MultiXacts yet. This is computed when first needed in a
* given transaction, and cleared attransaction end. We can compute it
* as the minimum of the validOldestMemberMXactId[] entries at the time
* we compute it (using nextMXact if none areva lid). Each backend is
* required not to attempt to access any SLRUdata for MultiXactIds older
* than its own OldestVisibleMXactId[] setting;this is necessary because
* the checkpointer could truncate away suchdata at any instant.
*
* The checkpointer can compute the safetruncation point as the oldest
* valid value among all theOldestMemberMXactId[] and
* OldestVisibleMXactId[] entries, or nextMXactif none are valid.
* Clearly, it is not possible for anylater-computed OldestVisibleMXactId
* value to be older than this, and so there isno risk of truncating data
* that is still needed.
*/
MultiXactIdperBackendXactIds[1]; /* VARIABLE LENGTH ARRAY */
} MultiXactStateData;
下面看看初始化完"MultiXactOffset Ctl"、"MultiXactOffset Ctl"及"Shared MultiXact State"相关结构后在内存中的结构图
初始化完MultiXact相关结构的内存结构图
为了精简上图,把创建shmem的哈希表索引"ShmemIndex"时创建的HCTL结构删掉了,这个结构的作用是记录创建可扩展哈希表的相关信息。增加了左边灰色底的部分,描述共享内存/shmem里各变量物理布局概览,由下往上,由低地址到高地址。其中的"MultiXactCtl"相关机构即MultiXactOffsetCtl和MultiXactMemberCtl的相关结构图下面分别给出,要不上面的图太大太复杂了。
MultiXact相关结构图