PostgreSQL 10.0 preview 功能增强 - CLOG oldest XID跟踪

less than 1 minute read

背景

PostgreSQL tuple中记录的xmin,xmax事务号是uint32类型,所以是一个rotate使用的方式,需要frozen。

CLOG存储的是oldest XID之后的XID,也就是说这个XID之后的事务,都保留了事务提交的状态值,之前的CLOG可能被删除或者正在被删除。

这个patch与从CLOG获取事务状态相关,允许提交一个任意的XID值,不管在CLOG是否在TRUNCATE过程中,都可以安全的返回被查询的事务号的提交状态,(通过跟踪TRUNCATE过程中被清除的事务状态实现)。

Track the oldest XID that can be safely looked up in CLOG.  
  
This provides infrastructure for looking up arbitrary, user-supplied  
XIDs without a risk of scary-looking failures from within the clog  
module.  Normally, the oldest XID that can be safely looked up in CLOG  
is the same as the oldest XID that can reused without causing  
wraparound, and the latter is already tracked.  However, while  
truncation is in progress, the values are different, so we must  
keep track of them separately.  
  
Craig Ringer, reviewed by Simon Riggs and by me.  
  
Discussion: http://postgr.es/m/CAMsr+YHQiWNEi0daCTboS40T+V5s_+dst3PYv_8v2wNVH+Xx4g@mail.gmail.com  

对此增加了一个等待事件信息

+         <entry><literal>CLogTruncationLock</></entry>  
+         <entry>Waiting to truncate the transaction log or waiting for transaction log truncation to finish.</entry>  

这个patch的讨论,详见邮件组,本文末尾URL。

PostgreSQL社区的作风非常严谨,一个patch可能在邮件组中讨论几个月甚至几年,根据大家的意见反复的修正,patch合并到master已经非常成熟,所以PostgreSQL的稳定性也是远近闻名的。

参考

https://git.postgresql.org/gitweb/?p=postgresql.git;a=commit;h=ea42cc18c35381f639d45628d792e790ff39e271

Flag Counter

digoal’s 大量PostgreSQL文章入口