mirror of
https://github.com/postgres/postgres.git
synced 2025-07-03 20:02:46 +03:00
Keep track of transaction commit timestamps
Transactions can now set their commit timestamp directly as they commit, or an external transaction commit timestamp can be fed from an outside system using the new function TransactionTreeSetCommitTsData(). This data is crash-safe, and truncated at Xid freeze point, same as pg_clog. This module is disabled by default because it causes a performance hit, but can be enabled in postgresql.conf requiring only a server restart. A new test in src/test/modules is included. Catalog version bumped due to the new subdirectory within PGDATA and a couple of new SQL functions. Authors: Álvaro Herrera and Petr Jelínek Reviewed to varying degrees by Michael Paquier, Andres Freund, Robert Haas, Amit Kapila, Fujii Masao, Jaime Casanova, Simon Riggs, Steven Singer, Peter Eisentraut
This commit is contained in:
@ -23,6 +23,7 @@
|
||||
#include <math.h>
|
||||
|
||||
#include "access/clog.h"
|
||||
#include "access/commit_ts.h"
|
||||
#include "access/genam.h"
|
||||
#include "access/heapam.h"
|
||||
#include "access/htup_details.h"
|
||||
@ -1071,10 +1072,12 @@ vac_truncate_clog(TransactionId frozenXID,
|
||||
return;
|
||||
|
||||
/*
|
||||
* Truncate CLOG to the oldest computed value. Note we don't truncate
|
||||
* multixacts; that will be done by the next checkpoint.
|
||||
* Truncate CLOG and CommitTs to the oldest computed value.
|
||||
* Note we don't truncate multixacts; that will be done by the next
|
||||
* checkpoint.
|
||||
*/
|
||||
TruncateCLOG(frozenXID);
|
||||
TruncateCommitTs(frozenXID);
|
||||
|
||||
/*
|
||||
* Update the wrap limit for GetNewTransactionId and creation of new
|
||||
@ -1084,6 +1087,7 @@ vac_truncate_clog(TransactionId frozenXID,
|
||||
*/
|
||||
SetTransactionIdLimit(frozenXID, oldestxid_datoid);
|
||||
SetMultiXactIdLimit(minMulti, minmulti_datoid);
|
||||
AdvanceOldestCommitTs(frozenXID);
|
||||
}
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user