2004-07-22 00:31:26 +02:00
|
|
|
/*
|
|
|
|
* xlog_internal.h
|
|
|
|
*
|
|
|
|
* PostgreSQL transaction log internal declarations
|
|
|
|
*
|
|
|
|
* NOTE: this file is intended to contain declarations useful for
|
|
|
|
* manipulating the XLOG files directly, but it is not supposed to be
|
2005-06-06 19:01:25 +02:00
|
|
|
* needed by rmgr routines (redo support for individual record types).
|
2014-11-06 12:52:08 +01:00
|
|
|
* So the XLogRecord typedef and associated stuff appear in xlogrecord.h.
|
2004-07-22 00:31:26 +02:00
|
|
|
*
|
2012-12-13 13:59:13 +01:00
|
|
|
* Note: This file must be includable in both frontend and backend contexts,
|
|
|
|
* to allow stand-alone tools like pg_receivexlog to deal with WAL files.
|
|
|
|
*
|
2015-01-06 17:43:47 +01:00
|
|
|
* Portions Copyright (c) 1996-2015, PostgreSQL Global Development Group
|
2004-07-22 00:31:26 +02:00
|
|
|
* Portions Copyright (c) 1994, Regents of the University of California
|
|
|
|
*
|
2010-09-20 22:08:53 +02:00
|
|
|
* src/include/access/xlog_internal.h
|
2004-07-22 00:31:26 +02:00
|
|
|
*/
|
|
|
|
#ifndef XLOG_INTERNAL_H
|
|
|
|
#define XLOG_INTERNAL_H
|
|
|
|
|
2012-12-13 13:59:13 +01:00
|
|
|
#include "access/xlogdefs.h"
|
Revamp the WAL record format.
Each WAL record now carries information about the modified relation and
block(s) in a standardized format. That makes it easier to write tools that
need that information, like pg_rewind, prefetching the blocks to speed up
recovery, etc.
There's a whole new API for building WAL records, replacing the XLogRecData
chains used previously. The new API consists of XLogRegister* functions,
which are called for each buffer and chunk of data that is added to the
record. The new API also gives more control over when a full-page image is
written, by passing flags to the XLogRegisterBuffer function.
This also simplifies the XLogReadBufferForRedo() calls. The function can dig
the relation and block number from the WAL record, so they no longer need to
be passed as arguments.
For the convenience of redo routines, XLogReader now disects each WAL record
after reading it, copying the main data part and the per-block data into
MAXALIGNed buffers. The data chunks are not aligned within the WAL record,
but the redo routines can assume that the pointers returned by XLogRecGet*
functions are. Redo routines are now passed the XLogReaderState, which
contains the record in the already-disected format, instead of the plain
XLogRecord.
The new record format also makes the fixed size XLogRecord header smaller,
by removing the xl_len field. The length of the "main data" portion is now
stored at the end of the WAL record, and there's a separate header after
XLogRecord for it. The alignment padding at the end of XLogRecord is also
removed. This compansates for the fact that the new format would otherwise
be more bulky than the old format.
Reviewed by Andres Freund, Amit Kapila, Michael Paquier, Alvaro Herrera,
Fujii Masao.
2014-11-20 16:56:26 +01:00
|
|
|
#include "access/xlogreader.h"
|
2012-12-13 13:59:13 +01:00
|
|
|
#include "datatype/timestamp.h"
|
|
|
|
#include "lib/stringinfo.h"
|
2011-09-09 19:23:41 +02:00
|
|
|
#include "pgtime.h"
|
2011-09-04 07:13:16 +02:00
|
|
|
#include "storage/block.h"
|
|
|
|
#include "storage/relfilenode.h"
|
2004-07-22 00:31:26 +02:00
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Each page of XLOG file has a header like this:
|
|
|
|
*/
|
Merge the various forms of transaction commit & abort records.
Since 465883b0a two versions of commit records have existed. A compact
version that was used when no cache invalidations, smgr unlinks and
similar were needed, and a full version that could deal with all
that. Additionally the full version was embedded into twophase commit
records.
That resulted in a measurable reduction in the size of the logged WAL in
some workloads. But more recently additions like logical decoding, which
e.g. needs information about the database something was executed on,
made it applicable in fewer situations. The static split generally made
it hard to expand the commit record, because concerns over the size made
it hard to add anything to the compact version.
Additionally it's not particularly pretty to have twophase.c insert
RM_XACT records.
Rejigger things so that the commit and abort records only have one form
each, including the twophase equivalents. The presence of the various
optional (in the sense of not being in every record) pieces is indicated
by a bits in the 'xinfo' flag. That flag previously was not included in
compact commit records. To prevent an increase in size due to its
presence, it's only included if necessary; signalled by a bit in the
xl_info bits available for xact.c, similar to heapam.c's
XLOG_HEAP_OPMASK/XLOG_HEAP_INIT_PAGE.
Twophase commit/aborts are now the same as their normal
counterparts. The original transaction's xid is included in an optional
data field.
This means that commit records generally are smaller, except in the case
of a transaction with subtransactions, but no other special cases; the
increase there is four bytes, which seems acceptable given that the more
common case of not having subtransactions shrank. The savings are
especially measurable for twophase commits, which previously always used
the full version; but will in practice only infrequently have required
that.
The motivation for this work are not the space savings and and
deduplication though; it's that it makes it easier to extend commit
records with additional information. That's just a few lines of code
now; without impacting the common case where that information is not
needed.
Discussion: 20150220152150.GD4149@awork2.anarazel.de,
235610.92468.qm%40web29004.mail.ird.yahoo.com
Reviewed-By: Heikki Linnakangas, Simon Riggs
2015-03-15 17:37:07 +01:00
|
|
|
#define XLOG_PAGE_MAGIC 0xD083 /* can be used as WAL version indicator */
|
2004-07-22 00:31:26 +02:00
|
|
|
|
|
|
|
typedef struct XLogPageHeaderData
|
|
|
|
{
|
|
|
|
uint16 xlp_magic; /* magic value for correctness checks */
|
|
|
|
uint16 xlp_info; /* flag bits, see below */
|
|
|
|
TimeLineID xlp_tli; /* TimeLineID of first record on page */
|
|
|
|
XLogRecPtr xlp_pageaddr; /* XLOG address of this page */
|
2012-06-24 17:15:00 +02:00
|
|
|
|
|
|
|
/*
|
|
|
|
* When there is not enough space on current page for whole record, we
|
|
|
|
* continue on the next page. xlp_rem_len is the number of bytes
|
2012-06-24 17:27:10 +02:00
|
|
|
* remaining from a previous page.
|
2012-06-24 17:15:00 +02:00
|
|
|
*
|
|
|
|
* Note that xl_rem_len includes backup-block data; that is, it tracks
|
|
|
|
* xl_tot_len not xl_len in the initial header. Also note that the
|
|
|
|
* continuation data isn't necessarily aligned.
|
|
|
|
*/
|
|
|
|
uint32 xlp_rem_len; /* total len of remaining data for record */
|
2004-07-22 00:31:26 +02:00
|
|
|
} XLogPageHeaderData;
|
|
|
|
|
|
|
|
#define SizeOfXLogShortPHD MAXALIGN(sizeof(XLogPageHeaderData))
|
|
|
|
|
|
|
|
typedef XLogPageHeaderData *XLogPageHeader;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* When the XLP_LONG_HEADER flag is set, we store additional fields in the
|
|
|
|
* page header. (This is ordinarily done just in the first page of an
|
2004-08-29 07:07:03 +02:00
|
|
|
* XLOG file.) The additional fields serve to identify the file accurately.
|
2004-07-22 00:31:26 +02:00
|
|
|
*/
|
|
|
|
typedef struct XLogLongPageHeaderData
|
|
|
|
{
|
|
|
|
XLogPageHeaderData std; /* standard header fields */
|
|
|
|
uint64 xlp_sysid; /* system identifier from pg_control */
|
|
|
|
uint32 xlp_seg_size; /* just as a cross-check */
|
2006-04-05 05:34:05 +02:00
|
|
|
uint32 xlp_xlog_blcksz; /* just as a cross-check */
|
2004-07-22 00:31:26 +02:00
|
|
|
} XLogLongPageHeaderData;
|
|
|
|
|
|
|
|
#define SizeOfXLogLongPHD MAXALIGN(sizeof(XLogLongPageHeaderData))
|
|
|
|
|
|
|
|
typedef XLogLongPageHeaderData *XLogLongPageHeader;
|
|
|
|
|
|
|
|
/* When record crosses page boundary, set this flag in new page's header */
|
|
|
|
#define XLP_FIRST_IS_CONTRECORD 0x0001
|
|
|
|
/* This flag indicates a "long" page header */
|
|
|
|
#define XLP_LONG_HEADER 0x0002
|
2011-12-12 22:22:14 +01:00
|
|
|
/* This flag indicates backup blocks starting in this page are optional */
|
|
|
|
#define XLP_BKP_REMOVABLE 0x0004
|
2004-07-22 00:31:26 +02:00
|
|
|
/* All defined flag bits in xlp_info (used for validity checking of header) */
|
2011-12-12 22:22:14 +01:00
|
|
|
#define XLP_ALL_FLAGS 0x0007
|
2004-07-22 00:31:26 +02:00
|
|
|
|
|
|
|
#define XLogPageHeaderSize(hdr) \
|
|
|
|
(((hdr)->xlp_info & XLP_LONG_HEADER) ? SizeOfXLogLongPHD : SizeOfXLogShortPHD)
|
|
|
|
|
|
|
|
/*
|
2012-06-24 17:06:38 +02:00
|
|
|
* The XLOG is split into WAL segments (physical files) of the size indicated
|
|
|
|
* by XLOG_SEG_SIZE.
|
2004-07-22 00:31:26 +02:00
|
|
|
*/
|
|
|
|
#define XLogSegSize ((uint32) XLOG_SEG_SIZE)
|
2012-06-24 20:41:23 +02:00
|
|
|
#define XLogSegmentsPerXLogId (UINT64CONST(0x100000000) / XLOG_SEG_SIZE)
|
2004-07-22 00:31:26 +02:00
|
|
|
|
2012-06-24 17:06:38 +02:00
|
|
|
#define XLogSegNoOffsetToRecPtr(segno, offset, dest) \
|
2012-06-24 17:51:37 +02:00
|
|
|
(dest) = (segno) * XLOG_SEG_SIZE + (offset)
|
2004-07-22 00:31:26 +02:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Compute ID and segment from an XLogRecPtr.
|
|
|
|
*
|
|
|
|
* For XLByteToSeg, do the computation at face value. For XLByteToPrevSeg,
|
2014-05-06 18:12:18 +02:00
|
|
|
* a boundary byte is taken to be in the previous segment. This is suitable
|
2004-07-22 00:31:26 +02:00
|
|
|
* for deciding which segment to write given a pointer to a record end,
|
2012-06-24 17:51:37 +02:00
|
|
|
* for example.
|
2004-07-22 00:31:26 +02:00
|
|
|
*/
|
2013-05-29 22:58:43 +02:00
|
|
|
#define XLByteToSeg(xlrp, logSegNo) \
|
2012-06-24 17:51:37 +02:00
|
|
|
logSegNo = (xlrp) / XLogSegSize
|
2012-06-24 17:06:38 +02:00
|
|
|
|
2013-05-29 22:58:43 +02:00
|
|
|
#define XLByteToPrevSeg(xlrp, logSegNo) \
|
2012-06-24 17:51:37 +02:00
|
|
|
logSegNo = ((xlrp) - 1) / XLogSegSize
|
2004-07-22 00:31:26 +02:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Is an XLogRecPtr within a particular XLOG segment?
|
|
|
|
*
|
|
|
|
* For XLByteInSeg, do the computation at face value. For XLByteInPrevSeg,
|
|
|
|
* a boundary byte is taken to be in the previous segment.
|
|
|
|
*/
|
2013-05-29 22:58:43 +02:00
|
|
|
#define XLByteInSeg(xlrp, logSegNo) \
|
2012-06-24 17:51:37 +02:00
|
|
|
(((xlrp) / XLogSegSize) == (logSegNo))
|
2004-07-22 00:31:26 +02:00
|
|
|
|
2013-05-29 22:58:43 +02:00
|
|
|
#define XLByteInPrevSeg(xlrp, logSegNo) \
|
2012-06-24 17:51:37 +02:00
|
|
|
((((xlrp) - 1) / XLogSegSize) == (logSegNo))
|
|
|
|
|
|
|
|
/* Check if an XLogRecPtr value is in a plausible range */
|
|
|
|
#define XRecOffIsValid(xlrp) \
|
2012-06-25 18:14:43 +02:00
|
|
|
((xlrp) % XLOG_BLCKSZ >= SizeOfXLogShortPHD)
|
2004-07-22 00:31:26 +02:00
|
|
|
|
2005-07-04 06:51:52 +02:00
|
|
|
/*
|
|
|
|
* The XLog directory and control file (relative to $PGDATA)
|
|
|
|
*/
|
|
|
|
#define XLOGDIR "pg_xlog"
|
|
|
|
#define XLOG_CONTROL_FILE "global/pg_control"
|
|
|
|
|
2004-07-22 00:31:26 +02:00
|
|
|
/*
|
|
|
|
* These macros encapsulate knowledge about the exact layout of XLog file
|
|
|
|
* names, timeline history file names, and archive-status file names.
|
|
|
|
*/
|
2004-08-03 22:32:36 +02:00
|
|
|
#define MAXFNAMELEN 64
|
2004-07-22 00:31:26 +02:00
|
|
|
|
2012-06-24 17:06:38 +02:00
|
|
|
#define XLogFileName(fname, tli, logSegNo) \
|
|
|
|
snprintf(fname, MAXFNAMELEN, "%08X%08X%08X", tli, \
|
|
|
|
(uint32) ((logSegNo) / XLogSegmentsPerXLogId), \
|
|
|
|
(uint32) ((logSegNo) % XLogSegmentsPerXLogId))
|
|
|
|
|
|
|
|
#define XLogFromFileName(fname, tli, logSegNo) \
|
|
|
|
do { \
|
|
|
|
uint32 log; \
|
|
|
|
uint32 seg; \
|
2013-05-29 22:58:43 +02:00
|
|
|
sscanf(fname, "%08X%08X%08X", tli, &log, &seg); \
|
|
|
|
*logSegNo = (uint64) log * XLogSegmentsPerXLogId + seg; \
|
2012-06-24 17:06:38 +02:00
|
|
|
} while (0)
|
2010-04-12 12:40:43 +02:00
|
|
|
|
2012-06-24 17:06:38 +02:00
|
|
|
#define XLogFilePath(path, tli, logSegNo) \
|
|
|
|
snprintf(path, MAXPGPATH, XLOGDIR "/%08X%08X%08X", tli, \
|
|
|
|
(uint32) ((logSegNo) / XLogSegmentsPerXLogId), \
|
|
|
|
(uint32) ((logSegNo) % XLogSegmentsPerXLogId))
|
2004-07-22 00:31:26 +02:00
|
|
|
|
|
|
|
#define TLHistoryFileName(fname, tli) \
|
|
|
|
snprintf(fname, MAXFNAMELEN, "%08X.history", tli)
|
|
|
|
|
|
|
|
#define TLHistoryFilePath(path, tli) \
|
2005-07-04 06:51:52 +02:00
|
|
|
snprintf(path, MAXPGPATH, XLOGDIR "/%08X.history", tli)
|
2004-07-22 00:31:26 +02:00
|
|
|
|
|
|
|
#define StatusFilePath(path, xlog, suffix) \
|
2005-07-04 06:51:52 +02:00
|
|
|
snprintf(path, MAXPGPATH, XLOGDIR "/archive_status/%s%s", xlog, suffix)
|
2004-07-22 00:31:26 +02:00
|
|
|
|
2012-06-24 17:06:38 +02:00
|
|
|
#define BackupHistoryFileName(fname, tli, logSegNo, offset) \
|
|
|
|
snprintf(fname, MAXFNAMELEN, "%08X%08X%08X.%08X.backup", tli, \
|
|
|
|
(uint32) ((logSegNo) / XLogSegmentsPerXLogId), \
|
|
|
|
(uint32) ((logSegNo) % XLogSegmentsPerXLogId), offset)
|
2004-08-03 22:32:36 +02:00
|
|
|
|
2012-06-24 17:06:38 +02:00
|
|
|
#define BackupHistoryFilePath(path, tli, logSegNo, offset) \
|
|
|
|
snprintf(path, MAXPGPATH, XLOGDIR "/%08X%08X%08X.%08X.backup", tli, \
|
|
|
|
(uint32) ((logSegNo) / XLogSegmentsPerXLogId), \
|
|
|
|
(uint32) ((logSegNo) % XLogSegmentsPerXLogId), offset)
|
2004-07-22 00:31:26 +02:00
|
|
|
|
2012-11-28 16:35:01 +01:00
|
|
|
/*
|
|
|
|
* Information logged when we detect a change in one of the parameters
|
|
|
|
* important for Hot Standby.
|
|
|
|
*/
|
|
|
|
typedef struct xl_parameter_change
|
|
|
|
{
|
|
|
|
int MaxConnections;
|
Add new GUC, max_worker_processes, limiting number of bgworkers.
In 9.3, there's no particular limit on the number of bgworkers;
instead, we just count up the number that are actually registered,
and use that to set MaxBackends. However, that approach causes
problems for Hot Standby, which needs both MaxBackends and the
size of the lock table to be the same on the standby as on the
master, yet it may not be desirable to run the same bgworkers in
both places. 9.3 handles that by failing to notice the problem,
which will probably work fine in nearly all cases anyway, but is
not theoretically sound.
A further problem with simply counting the number of registered
workers is that new workers can't be registered without a
postmaster restart. This is inconvenient for administrators,
since bouncing the postmaster causes an interruption of service.
Moreover, there are a number of applications for background
processes where, by necessity, the background process must be
started on the fly (e.g. parallel query). While this patch
doesn't actually make it possible to register new background
workers after startup time, it's a necessary prerequisite.
Patch by me. Review by Michael Paquier.
2013-07-04 17:24:24 +02:00
|
|
|
int max_worker_processes;
|
2012-11-28 16:35:01 +01:00
|
|
|
int max_prepared_xacts;
|
|
|
|
int max_locks_per_xact;
|
|
|
|
int wal_level;
|
2013-12-20 19:33:16 +01:00
|
|
|
bool wal_log_hints;
|
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
2014-12-03 15:53:02 +01:00
|
|
|
bool track_commit_timestamp;
|
2012-11-28 16:35:01 +01:00
|
|
|
} xl_parameter_change;
|
|
|
|
|
|
|
|
/* logs restore point */
|
|
|
|
typedef struct xl_restore_point
|
|
|
|
{
|
|
|
|
TimestampTz rp_time;
|
|
|
|
char rp_name[MAXFNAMELEN];
|
|
|
|
} xl_restore_point;
|
|
|
|
|
2013-01-29 01:06:15 +01:00
|
|
|
/* End of recovery mark, when we don't do an END_OF_RECOVERY checkpoint */
|
|
|
|
typedef struct xl_end_of_recovery
|
|
|
|
{
|
|
|
|
TimestampTz end_time;
|
2013-02-11 17:13:09 +01:00
|
|
|
TimeLineID ThisTimeLineID; /* new TLI */
|
|
|
|
TimeLineID PrevTimeLineID; /* previous TLI we forked off from */
|
2013-01-29 01:06:15 +01:00
|
|
|
} xl_end_of_recovery;
|
2004-07-22 00:31:26 +02:00
|
|
|
|
Revamp the WAL record format.
Each WAL record now carries information about the modified relation and
block(s) in a standardized format. That makes it easier to write tools that
need that information, like pg_rewind, prefetching the blocks to speed up
recovery, etc.
There's a whole new API for building WAL records, replacing the XLogRecData
chains used previously. The new API consists of XLogRegister* functions,
which are called for each buffer and chunk of data that is added to the
record. The new API also gives more control over when a full-page image is
written, by passing flags to the XLogRegisterBuffer function.
This also simplifies the XLogReadBufferForRedo() calls. The function can dig
the relation and block number from the WAL record, so they no longer need to
be passed as arguments.
For the convenience of redo routines, XLogReader now disects each WAL record
after reading it, copying the main data part and the per-block data into
MAXALIGNed buffers. The data chunks are not aligned within the WAL record,
but the redo routines can assume that the pointers returned by XLogRecGet*
functions are. Redo routines are now passed the XLogReaderState, which
contains the record in the already-disected format, instead of the plain
XLogRecord.
The new record format also makes the fixed size XLogRecord header smaller,
by removing the xl_len field. The length of the "main data" portion is now
stored at the end of the WAL record, and there's a separate header after
XLogRecord for it. The alignment padding at the end of XLogRecord is also
removed. This compansates for the fact that the new format would otherwise
be more bulky than the old format.
Reviewed by Andres Freund, Amit Kapila, Michael Paquier, Alvaro Herrera,
Fujii Masao.
2014-11-20 16:56:26 +01:00
|
|
|
/*
|
|
|
|
* The functions in xloginsert.c construct a chain of XLogRecData structs
|
|
|
|
* to represent the final WAL record.
|
|
|
|
*/
|
|
|
|
typedef struct XLogRecData
|
|
|
|
{
|
|
|
|
struct XLogRecData *next; /* next struct in chain, or NULL */
|
|
|
|
char *data; /* start of rmgr data to include */
|
|
|
|
uint32 len; /* length of rmgr data to include */
|
|
|
|
} XLogRecData;
|
|
|
|
|
2014-11-25 21:13:30 +01:00
|
|
|
/*
|
|
|
|
* Recovery target action.
|
|
|
|
*/
|
|
|
|
typedef enum
|
|
|
|
{
|
|
|
|
RECOVERY_TARGET_ACTION_PAUSE,
|
|
|
|
RECOVERY_TARGET_ACTION_PROMOTE,
|
|
|
|
RECOVERY_TARGET_ACTION_SHUTDOWN,
|
|
|
|
} RecoveryTargetAction;
|
|
|
|
|
2004-07-22 00:31:26 +02:00
|
|
|
/*
|
|
|
|
* Method table for resource managers.
|
|
|
|
*
|
2013-02-05 21:21:29 +01:00
|
|
|
* This struct must be kept in sync with the PG_RMGR definition in
|
|
|
|
* rmgr.c.
|
|
|
|
*
|
2014-09-19 15:17:12 +02:00
|
|
|
* rm_identify must return a name for the record based on xl_info (without
|
|
|
|
* reference to the rmid). For example, XLOG_BTREE_VACUUM would be named
|
|
|
|
* "VACUUM". rm_desc can then be called to obtain additional detail for the
|
|
|
|
* record, if available (e.g. the last block).
|
|
|
|
*
|
2013-02-05 21:21:29 +01:00
|
|
|
* RmgrTable[] is indexed by RmgrId values (see rmgrlist.h).
|
2004-07-22 00:31:26 +02:00
|
|
|
*/
|
|
|
|
typedef struct RmgrData
|
|
|
|
{
|
|
|
|
const char *rm_name;
|
Revamp the WAL record format.
Each WAL record now carries information about the modified relation and
block(s) in a standardized format. That makes it easier to write tools that
need that information, like pg_rewind, prefetching the blocks to speed up
recovery, etc.
There's a whole new API for building WAL records, replacing the XLogRecData
chains used previously. The new API consists of XLogRegister* functions,
which are called for each buffer and chunk of data that is added to the
record. The new API also gives more control over when a full-page image is
written, by passing flags to the XLogRegisterBuffer function.
This also simplifies the XLogReadBufferForRedo() calls. The function can dig
the relation and block number from the WAL record, so they no longer need to
be passed as arguments.
For the convenience of redo routines, XLogReader now disects each WAL record
after reading it, copying the main data part and the per-block data into
MAXALIGNed buffers. The data chunks are not aligned within the WAL record,
but the redo routines can assume that the pointers returned by XLogRecGet*
functions are. Redo routines are now passed the XLogReaderState, which
contains the record in the already-disected format, instead of the plain
XLogRecord.
The new record format also makes the fixed size XLogRecord header smaller,
by removing the xl_len field. The length of the "main data" portion is now
stored at the end of the WAL record, and there's a separate header after
XLogRecord for it. The alignment padding at the end of XLogRecord is also
removed. This compansates for the fact that the new format would otherwise
be more bulky than the old format.
Reviewed by Andres Freund, Amit Kapila, Michael Paquier, Alvaro Herrera,
Fujii Masao.
2014-11-20 16:56:26 +01:00
|
|
|
void (*rm_redo) (XLogReaderState *record);
|
|
|
|
void (*rm_desc) (StringInfo buf, XLogReaderState *record);
|
2014-09-19 15:17:12 +02:00
|
|
|
const char *(*rm_identify) (uint8 info);
|
2004-07-22 00:31:26 +02:00
|
|
|
void (*rm_startup) (void);
|
|
|
|
void (*rm_cleanup) (void);
|
|
|
|
} RmgrData;
|
|
|
|
|
|
|
|
extern const RmgrData RmgrTable[];
|
|
|
|
|
2006-10-04 02:30:14 +02:00
|
|
|
/*
|
2011-11-01 18:14:47 +01:00
|
|
|
* Exported to support xlog switching from checkpointer
|
2006-08-18 01:04:10 +02:00
|
|
|
*/
|
2008-02-17 03:09:32 +01:00
|
|
|
extern pg_time_t GetLastSegSwitchTime(void);
|
2006-08-18 01:04:10 +02:00
|
|
|
extern XLogRecPtr RequestXLogSwitch(void);
|
|
|
|
|
2012-10-02 12:37:19 +02:00
|
|
|
extern void GetOldestRestartPoint(XLogRecPtr *oldrecptr, TimeLineID *oldtli);
|
|
|
|
|
|
|
|
/*
|
2014-05-06 18:12:18 +02:00
|
|
|
* Exported for the functions in timeline.c and xlogarchive.c. Only valid
|
2012-10-02 12:37:19 +02:00
|
|
|
* in the startup process.
|
|
|
|
*/
|
2013-03-07 11:18:41 +01:00
|
|
|
extern bool ArchiveRecoveryRequested;
|
2012-10-02 12:37:19 +02:00
|
|
|
extern bool InArchiveRecovery;
|
|
|
|
extern bool StandbyMode;
|
|
|
|
extern char *recoveryRestoreCommand;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Prototypes for functions in xlogarchive.c
|
|
|
|
*/
|
|
|
|
extern bool RestoreArchivedFile(char *path, const char *xlogfname,
|
2012-11-19 09:02:25 +01:00
|
|
|
const char *recovername, off_t expectedSize,
|
|
|
|
bool cleanupEnabled);
|
2012-10-02 12:37:19 +02:00
|
|
|
extern void ExecuteRecoveryCommand(char *command, char *commandName,
|
|
|
|
bool failOnerror);
|
2013-05-29 22:58:43 +02:00
|
|
|
extern void KeepFileRestoredFromArchive(char *path, char *xlogfname);
|
2012-10-02 12:37:19 +02:00
|
|
|
extern void XLogArchiveNotify(const char *xlog);
|
|
|
|
extern void XLogArchiveNotifySeg(XLogSegNo segno);
|
2012-08-09 00:58:49 +02:00
|
|
|
extern void XLogArchiveForceDone(const char *xlog);
|
2012-10-02 12:37:19 +02:00
|
|
|
extern bool XLogArchiveCheckDone(const char *xlog);
|
|
|
|
extern bool XLogArchiveIsBusy(const char *xlog);
|
Don't archive bogus recycled or preallocated files after timeline switch.
After a timeline switch, we would leave behind recycled WAL segments that
are in the future, but on the old timeline. After promotion, and after they
become old enough to be recycled again, we would notice that they don't have
a .ready or .done file, create a .ready file for them, and archive them.
That's bogus, because the files contain garbage, recycled from an older
timeline (or prealloced as zeros). We shouldn't archive such files.
This could happen when we're following a timeline switch during replay, or
when we switch to new timeline at end-of-recovery.
To fix, whenever we switch to a new timeline, scan the data directory for
WAL segments on the old timeline, but with a higher segment number, and
remove them. Those don't belong to our timeline history, and are most
likely bogus recycled or preallocated files. They could also be valid files
that we streamed from the primary ahead of time, but in any case, they're
not needed to recover to the new timeline.
2015-04-13 15:53:49 +02:00
|
|
|
extern bool XLogArchiveIsReady(const char *xlog);
|
2012-10-02 12:37:19 +02:00
|
|
|
extern void XLogArchiveCleanup(const char *xlog);
|
|
|
|
|
2004-07-22 00:31:26 +02:00
|
|
|
#endif /* XLOG_INTERNAL_H */
|