diff options
| author | Tom Lane | 2006-11-05 22:42:10 +0000 |
|---|---|---|
| committer | Tom Lane | 2006-11-05 22:42:10 +0000 |
| commit | 48188e1621bb6711e7d092bee48523b18cd80177 (patch) | |
| tree | 524459ab58f8740a23efa7b7b521833646c678ba /src/include/access | |
| parent | 10c70b86023001dc6d9028737afc97850b86e58f (diff) | |
Fix recently-understood problems with handling of XID freezing, particularly
in PITR scenarios. We now WAL-log the replacement of old XIDs with
FrozenTransactionId, so that such replacement is guaranteed to propagate to
PITR slave databases. Also, rather than relying on hint-bit updates to be
preserved, pg_clog is not truncated until all instances of an XID are known to
have been replaced by FrozenTransactionId. Add new GUC variables and
pg_autovacuum columns to allow management of the freezing policy, so that
users can trade off the size of pg_clog against the amount of freezing work
done. Revise the already-existing code that forces autovacuum of tables
approaching the wraparound point to make it more bulletproof; also, revise the
autovacuum logic so that anti-wraparound vacuuming is done per-table rather
than per-database. initdb forced because of changes in pg_class, pg_database,
and pg_autovacuum catalogs. Heikki Linnakangas, Simon Riggs, and Tom Lane.
Diffstat (limited to 'src/include/access')
| -rw-r--r-- | src/include/access/clog.h | 3 | ||||
| -rw-r--r-- | src/include/access/heapam.h | 14 | ||||
| -rw-r--r-- | src/include/access/htup.h | 20 | ||||
| -rw-r--r-- | src/include/access/rmgr.h | 6 | ||||
| -rw-r--r-- | src/include/access/transam.h | 9 | ||||
| -rw-r--r-- | src/include/access/xlog.h | 3 |
6 files changed, 44 insertions, 11 deletions
diff --git a/src/include/access/clog.h b/src/include/access/clog.h index 999f15bdf7f..0cb76000a29 100644 --- a/src/include/access/clog.h +++ b/src/include/access/clog.h @@ -6,7 +6,7 @@ * Portions Copyright (c) 1996-2006, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $PostgreSQL: pgsql/src/include/access/clog.h,v 1.17 2006/03/24 04:32:13 tgl Exp $ + * $PostgreSQL: pgsql/src/include/access/clog.h,v 1.18 2006/11/05 22:42:09 tgl Exp $ */ #ifndef CLOG_H #define CLOG_H @@ -46,6 +46,7 @@ extern void TruncateCLOG(TransactionId oldestXact); /* XLOG stuff */ #define CLOG_ZEROPAGE 0x00 +#define CLOG_TRUNCATE 0x10 extern void clog_redo(XLogRecPtr lsn, XLogRecord *record); extern void clog_desc(StringInfo buf, uint8 xl_info, char *rec); diff --git a/src/include/access/heapam.h b/src/include/access/heapam.h index b2dd0f3390d..4b3dd57534c 100644 --- a/src/include/access/heapam.h +++ b/src/include/access/heapam.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2006, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $PostgreSQL: pgsql/src/include/access/heapam.h,v 1.116 2006/10/04 00:30:07 momjian Exp $ + * $PostgreSQL: pgsql/src/include/access/heapam.h,v 1.117 2006/11/05 22:42:10 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -170,6 +170,8 @@ extern HTSU_Result heap_lock_tuple(Relation relation, HeapTuple tuple, TransactionId *update_xmax, CommandId cid, LockTupleMode mode, bool nowait); extern void heap_inplace_update(Relation relation, HeapTuple tuple); +extern bool heap_freeze_tuple(HeapTupleHeader tuple, TransactionId cutoff_xid, + Buffer buf); extern Oid simple_heap_insert(Relation relation, HeapTuple tup); extern void simple_heap_delete(Relation relation, ItemPointer tid); @@ -181,11 +183,17 @@ extern void heap_restrpos(HeapScanDesc scan); extern void heap_redo(XLogRecPtr lsn, XLogRecord *rptr); extern void heap_desc(StringInfo buf, uint8 xl_info, char *rec); -extern XLogRecPtr log_heap_clean(Relation reln, Buffer buffer, - OffsetNumber *unused, int uncnt); +extern void heap2_redo(XLogRecPtr lsn, XLogRecord *rptr); +extern void heap2_desc(StringInfo buf, uint8 xl_info, char *rec); + extern XLogRecPtr log_heap_move(Relation reln, Buffer oldbuf, ItemPointerData from, Buffer newbuf, HeapTuple newtup); +extern XLogRecPtr log_heap_clean(Relation reln, Buffer buffer, + OffsetNumber *unused, int uncnt); +extern XLogRecPtr log_heap_freeze(Relation reln, Buffer buffer, + TransactionId cutoff_xid, + OffsetNumber *offsets, int offcnt); /* in common/heaptuple.c */ extern Size heap_compute_data_size(TupleDesc tupleDesc, diff --git a/src/include/access/htup.h b/src/include/access/htup.h index edfce82bc04..ed1f082de05 100644 --- a/src/include/access/htup.h +++ b/src/include/access/htup.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2006, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $PostgreSQL: pgsql/src/include/access/htup.h,v 1.86 2006/10/04 00:30:07 momjian Exp $ + * $PostgreSQL: pgsql/src/include/access/htup.h,v 1.87 2006/11/05 22:42:10 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -510,6 +510,13 @@ typedef HeapTupleData *HeapTuple; * we can (and we do) restore entire page in redo */ #define XLOG_HEAP_INIT_PAGE 0x80 +/* + * We ran out of opcodes, so heapam.c now has a second RmgrId. These opcodes + * are associated with RM_HEAP2_ID, but are not logically different from + * the ones above associated with RM_HEAP_ID. We apply XLOG_HEAP_OPMASK, + * although currently XLOG_HEAP_INIT_PAGE is not used for any of these. + */ +#define XLOG_HEAP2_FREEZE 0x00 /* * All what we need to find changed tuple @@ -613,4 +620,15 @@ typedef struct xl_heap_inplace #define SizeOfHeapInplace (offsetof(xl_heap_inplace, target) + SizeOfHeapTid) +/* This is what we need to know about tuple freezing during vacuum */ +typedef struct xl_heap_freeze +{ + RelFileNode node; + BlockNumber block; + TransactionId cutoff_xid; + /* TUPLE OFFSET NUMBERS FOLLOW AT THE END */ +} xl_heap_freeze; + +#define SizeOfHeapFreeze (offsetof(xl_heap_freeze, cutoff_xid) + sizeof(TransactionId)) + #endif /* HTUP_H */ diff --git a/src/include/access/rmgr.h b/src/include/access/rmgr.h index 471b0cfb764..7be2dfc9f65 100644 --- a/src/include/access/rmgr.h +++ b/src/include/access/rmgr.h @@ -3,7 +3,7 @@ * * Resource managers definition * - * $PostgreSQL: pgsql/src/include/access/rmgr.h,v 1.16 2006/05/02 11:28:55 teodor Exp $ + * $PostgreSQL: pgsql/src/include/access/rmgr.h,v 1.17 2006/11/05 22:42:10 tgl Exp $ */ #ifndef RMGR_H #define RMGR_H @@ -12,6 +12,9 @@ typedef uint8 RmgrId; /* * Built-in resource managers + * + * Note: RM_MAX_ID could be as much as 255 without breaking the XLOG file + * format, but we keep it small to minimize the size of RmgrTable[]. */ #define RM_XLOG_ID 0 #define RM_XACT_ID 1 @@ -20,6 +23,7 @@ typedef uint8 RmgrId; #define RM_DBASE_ID 4 #define RM_TBLSPC_ID 5 #define RM_MULTIXACT_ID 6 +#define RM_HEAP2_ID 9 #define RM_HEAP_ID 10 #define RM_BTREE_ID 11 #define RM_HASH_ID 12 diff --git a/src/include/access/transam.h b/src/include/access/transam.h index f1b91145f67..96cc65f94d5 100644 --- a/src/include/access/transam.h +++ b/src/include/access/transam.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2006, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $PostgreSQL: pgsql/src/include/access/transam.h,v 1.58 2006/07/10 16:20:51 alvherre Exp $ + * $PostgreSQL: pgsql/src/include/access/transam.h,v 1.59 2006/11/05 22:42:10 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -23,7 +23,7 @@ * always be considered valid. * * FirstNormalTransactionId is the first "normal" transaction id. - * Note: if you need to change it, you must change it in pg_class.h as well. + * Note: if you need to change it, you must change pg_class.h as well. * ---------------- */ #define InvalidTransactionId ((TransactionId) 0) @@ -88,6 +88,9 @@ typedef struct VariableCacheData Oid nextOid; /* next OID to assign */ uint32 oidCount; /* OIDs available before must do XLOG work */ TransactionId nextXid; /* next XID to assign */ + + TransactionId oldestXid; /* cluster-wide minimum datfrozenxid */ + TransactionId xidVacLimit; /* start forcing autovacuums here */ TransactionId xidWarnLimit; /* start complaining here */ TransactionId xidStopLimit; /* refuse to advance nextXid beyond here */ TransactionId xidWrapLimit; /* where the world ends */ @@ -124,7 +127,7 @@ extern bool TransactionIdFollowsOrEquals(TransactionId id1, TransactionId id2); /* in transam/varsup.c */ extern TransactionId GetNewTransactionId(bool isSubXact); extern TransactionId ReadNewTransactionId(void); -extern void SetTransactionIdLimit(TransactionId oldest_datminxid, +extern void SetTransactionIdLimit(TransactionId oldest_datfrozenxid, Name oldest_datname); extern Oid GetNewObjectId(void); diff --git a/src/include/access/xlog.h b/src/include/access/xlog.h index a5ae94b91aa..93c95aa4627 100644 --- a/src/include/access/xlog.h +++ b/src/include/access/xlog.h @@ -6,7 +6,7 @@ * Portions Copyright (c) 1996-2006, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $PostgreSQL: pgsql/src/include/access/xlog.h,v 1.74 2006/08/21 16:16:31 tgl Exp $ + * $PostgreSQL: pgsql/src/include/access/xlog.h,v 1.75 2006/11/05 22:42:10 tgl Exp $ */ #ifndef XLOG_H #define XLOG_H @@ -165,7 +165,6 @@ extern void InitXLOGAccess(void); extern void CreateCheckPoint(bool shutdown, bool force); extern void XLogPutNextOid(Oid nextOid); extern XLogRecPtr GetRedoRecPtr(void); -extern TransactionId GetRecentNextXid(void); extern void GetNextXidAndEpoch(TransactionId *xid, uint32 *epoch); #endif /* XLOG_H */ |
