pg会进行常规的清理老的事务标识符活动,也是就是冻结,来延迟事务wrapround,在pg中一行有2个途径,行版本死亡需要被vacuum清除,或是一个行的版本足够老需要被冻结,

对一个数据库进行vacuum操作

psql -c "VACUUM" postgres

pg使用4字节长度来表示标识符,所以事务的个数是有限的,分配标识符是通过循环的方式进行的,当出啊先wrapround的时候,可能会报下面的错误

ERROR: database is not accepting commands to avoid wraparound data loss in database
"template0"
HINT: Stop the postmaster and use a standalone backend to vacuum that database


standalone backend的方式如下:

$ postgres --single -D /full/path/to/datadir postgres

backend> VACUUM;

执行完后,退出终端


Prepared transactions are part of the "two-phase commit" feature, also known as 2PC. A
transaction commits in two stages rather than one, allowing multiple databases to have
synchronized commits. It's typical use is to combine multiple "resource managers" using
the XA protocol, usually provided by a Transaction Manager (TM), as used by the Java
Transaction API (JTA) and others. If none of that meant anything to you, then you probably
don't have any prepared transactions.