mirror of
https://github.com/postgres/postgres.git
synced 2026-02-26 19:30:25 -05:00
If a user requests the commit timestamp for a transaction old enough that its data is concurrently being truncated away by vacuum at just the right time, they would receive an ugly internal file-not-found error message from slru.c rather than the expected NULL return value. In a primary server, the window for the race is very small: the lookup has to occur exactly between the two calls by vacuum, and there's not a lot that happens between them (mostly just a multixact truncate). In a standby server, however, the window is larger because the truncation is executed as soon as the WAL record for it is replayed, but the advance of the oldest-Xid is not executed until the next checkpoint record. To fix in the primary, simply reverse the order of operations in vac_truncate_clog. To fix in the standby, augment the WAL truncation record so that the standby is aware of the new oldest-XID value and can apply the update immediately. WAL version bumped because of this. No backpatch, because of the low importance of the bug and its rarity. Author: Craig Ringer Reviewed-By: Petr Jelínek, Peter Eisentraut Discussion: https://postgr.es/m/CAMsr+YFhVtRQT1VAwC+WGbbxZZRzNou=N9Ed-FrCqkwQ8H8oJQ@mail.gmail.com
77 lines
2.3 KiB
C
77 lines
2.3 KiB
C
/*
|
|
* commit_ts.h
|
|
*
|
|
* PostgreSQL commit timestamp manager
|
|
*
|
|
* Portions Copyright (c) 1996-2017, PostgreSQL Global Development Group
|
|
* Portions Copyright (c) 1994, Regents of the University of California
|
|
*
|
|
* src/include/access/commit_ts.h
|
|
*/
|
|
#ifndef COMMIT_TS_H
|
|
#define COMMIT_TS_H
|
|
|
|
#include "access/xlog.h"
|
|
#include "datatype/timestamp.h"
|
|
#include "replication/origin.h"
|
|
#include "utils/guc.h"
|
|
|
|
|
|
extern PGDLLIMPORT bool track_commit_timestamp;
|
|
|
|
extern bool check_track_commit_timestamp(bool *newval, void **extra,
|
|
GucSource source);
|
|
|
|
extern void TransactionTreeSetCommitTsData(TransactionId xid, int nsubxids,
|
|
TransactionId *subxids, TimestampTz timestamp,
|
|
RepOriginId nodeid, bool write_xlog);
|
|
extern bool TransactionIdGetCommitTsData(TransactionId xid,
|
|
TimestampTz *ts, RepOriginId *nodeid);
|
|
extern TransactionId GetLatestCommitTsData(TimestampTz *ts,
|
|
RepOriginId *nodeid);
|
|
|
|
extern Size CommitTsShmemBuffers(void);
|
|
extern Size CommitTsShmemSize(void);
|
|
extern void CommitTsShmemInit(void);
|
|
extern void BootStrapCommitTs(void);
|
|
extern void StartupCommitTs(void);
|
|
extern void CommitTsParameterChange(bool xlrecvalue, bool pgcontrolvalue);
|
|
extern void CompleteCommitTsInitialization(void);
|
|
extern void ShutdownCommitTs(void);
|
|
extern void CheckPointCommitTs(void);
|
|
extern void ExtendCommitTs(TransactionId newestXact);
|
|
extern void TruncateCommitTs(TransactionId oldestXact);
|
|
extern void SetCommitTsLimit(TransactionId oldestXact,
|
|
TransactionId newestXact);
|
|
extern void AdvanceOldestCommitTsXid(TransactionId oldestXact);
|
|
|
|
/* XLOG stuff */
|
|
#define COMMIT_TS_ZEROPAGE 0x00
|
|
#define COMMIT_TS_TRUNCATE 0x10
|
|
#define COMMIT_TS_SETTS 0x20
|
|
|
|
typedef struct xl_commit_ts_set
|
|
{
|
|
TimestampTz timestamp;
|
|
RepOriginId nodeid;
|
|
TransactionId mainxid;
|
|
/* subxact Xids follow */
|
|
} xl_commit_ts_set;
|
|
|
|
#define SizeOfCommitTsSet (offsetof(xl_commit_ts_set, mainxid) + \
|
|
sizeof(TransactionId))
|
|
|
|
typedef struct xl_commit_ts_truncate
|
|
{
|
|
int pageno;
|
|
TransactionId oldestXid;
|
|
} xl_commit_ts_truncate;
|
|
|
|
#define SizeOfCommitTsTruncate (offsetof(xl_commit_ts_truncate, oldestXid) + \
|
|
sizeof(TransactionId))
|
|
|
|
extern void commit_ts_redo(XLogReaderState *record);
|
|
extern void commit_ts_desc(StringInfo buf, XLogReaderState *record);
|
|
extern const char *commit_ts_identify(uint8 info);
|
|
|
|
#endif /* COMMIT_TS_H */
|