Multixacts and Wraparound
Multixact IDs are used to support row locking by multiple transactions. Since there is only limited space in a tuple header to store lock information, that information is encoded as a “multiple transaction ID”, or multixact ID for short, whenever there is more than one transaction concurrently locking a row. Information about which transaction IDs are included in any particular multixact ID is stored separately in the pg_multixact subdirectory, and only the multixact ID appears in the xmax field in the tuple header. Like transaction IDs, multixact IDs are implemented as a 32-bit counter and corresponding storage, all of which requires careful aging management, storage cleanup, and wraparound handling. There is a separate storage area which holds the list of members in each multixact, which also uses a 32-bit counter and which must also be managed.
组合事务用于支持元组被多个事务同时锁定,当多个事务同时并发的锁定了一个元组时,由于元组头部只能记录较为有限的锁信息,锁定同一个元组的多个事务ID被编码为组合事务ID。而具体的哪些事务ID与组合事务ID相关,这部分信息被存放在pg_multixact子目录下,锁定元组的组合事务ID则存放在元组头信息中的xmax字段中。元组头信息中的t_infomask字段与宏定义HEAP_XMAX_IS_MULTI进行与操作即可判定xmax是否为组合事务