提交 6e715b6b 编写于 作者: A Ashwin Agrawal

Avoid could not open file pg_subtrans/xxx situation during recovery.

Initialize TransactionXmin to avoid situations where scanning pg_authid or other
tables mostly in BuildFlatFiles() via SnapshotNow may try to chase down
pg_subtrans for older "sub-committed" transaction. File corresponding to which
may not and is not supposed to exist. Setting TransactionXmin will avoid calling
SubTransGetParent() in TransactionIdDidCommit() for older XIDs. Also, along the
way initialize RecentGlobalXmin as Heap access method needs it set.

Repro for record of one such case:
```
CREATE ROLE foo;

BEGIN;
SAVEPOINT sp;
DROP ROLE foo;
RELEASE SAVEPOINT sp; -- this is key which marks in clog as sub-committed.

kill or gpstop -air
< N transactions to atleast cross pg_subtrans single file limit roughly
CLOG_XACTS_PER_BYTE * BLCKSZ* SLRU_PAGES_PER_SEGMENT >

restart -- errors recovery with missing pg_subtrans
```
上级 f785aed1
......@@ -6124,6 +6124,18 @@ StartupXLOG_InProduction(void)
elog(LOG, "Oldest active transaction from prepared transactions %u", oldestActiveXID);
/*
* Initialize TransactionXmin to current oldestActiveXID, generally
* initialized during GetSnapshotData(). This is to avoid situations where
* scanning pg_authid or other tables mostly in BuildFlatFiles() below via
* SnapshotNow may try to chase down pg_subtrans for older "sub-committed"
* transaction, file corresponding to which may not and is not supposed to
* exist. Setting this here will avoid calling SubTransGetParent() in
* TransactionIdDidCommit() for older XIDs. Also, set RecentGlobalXmin
* since Heap access method functions needs it to have good value as well.
*/
TransactionXmin = RecentGlobalXmin = oldestActiveXID;
/* Start up the commit log and related stuff, too */
StartupCLOG();
StartupSUBTRANS(oldestActiveXID);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册