2001-08-25 20:52:43 +02:00
|
|
|
/*
|
|
|
|
* rmgr.c
|
|
|
|
*
|
|
|
|
* Resource managers definition
|
|
|
|
*
|
2010-09-20 22:08:53 +02:00
|
|
|
* src/backend/access/transam/rmgr.c
|
2001-08-25 20:52:43 +02:00
|
|
|
*/
|
1999-09-27 17:48:12 +02:00
|
|
|
#include "postgres.h"
|
2001-08-25 20:52:43 +02:00
|
|
|
|
2019-11-12 04:00:16 +01:00
|
|
|
#include "access/brin_xlog.h"
|
2004-08-29 23:08:48 +02:00
|
|
|
#include "access/clog.h"
|
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
|
|
|
#include "access/commit_ts.h"
|
2019-11-12 04:00:16 +01:00
|
|
|
#include "access/generic_xlog.h"
|
2017-02-14 21:37:59 +01:00
|
|
|
#include "access/ginxlog.h"
|
|
|
|
#include "access/gistxlog.h"
|
2016-08-29 23:48:02 +02:00
|
|
|
#include "access/hash_xlog.h"
|
2012-08-29 01:02:00 +02:00
|
|
|
#include "access/heapam_xlog.h"
|
2005-06-08 17:50:28 +02:00
|
|
|
#include "access/multixact.h"
|
2017-02-14 21:37:59 +01:00
|
|
|
#include "access/nbtxlog.h"
|
|
|
|
#include "access/spgxlog.h"
|
2000-11-21 22:16:06 +01:00
|
|
|
#include "access/xact.h"
|
2004-07-22 00:31:26 +02:00
|
|
|
#include "access/xlog_internal.h"
|
2012-11-28 16:35:01 +01:00
|
|
|
#include "catalog/storage_xlog.h"
|
2015-03-09 14:49:10 +01:00
|
|
|
#include "commands/dbcommands_xlog.h"
|
2000-11-30 02:47:33 +01:00
|
|
|
#include "commands/sequence.h"
|
2004-08-29 23:08:48 +02:00
|
|
|
#include "commands/tablespace.h"
|
2016-04-06 11:05:41 +02:00
|
|
|
#include "replication/message.h"
|
Introduce replication progress tracking infrastructure.
When implementing a replication solution ontop of logical decoding, two
related problems exist:
* How to safely keep track of replication progress
* How to change replication behavior, based on the origin of a row;
e.g. to avoid loops in bi-directional replication setups
The solution to these problems, as implemented here, consist out of
three parts:
1) 'replication origins', which identify nodes in a replication setup.
2) 'replication progress tracking', which remembers, for each
replication origin, how far replay has progressed in a efficient and
crash safe manner.
3) The ability to filter out changes performed on the behest of a
replication origin during logical decoding; this allows complex
replication topologies. E.g. by filtering all replayed changes out.
Most of this could also be implemented in "userspace", e.g. by inserting
additional rows contain origin information, but that ends up being much
less efficient and more complicated. We don't want to require various
replication solutions to reimplement logic for this independently. The
infrastructure is intended to be generic enough to be reusable.
This infrastructure also replaces the 'nodeid' infrastructure of commit
timestamps. It is intended to provide all the former capabilities,
except that there's only 2^16 different origins; but now they integrate
with logical decoding. Additionally more functionality is accessible via
SQL. Since the commit timestamp infrastructure has also been introduced
in 9.5 (commit 73c986add) changing the API is not a problem.
For now the number of origins for which the replication progress can be
tracked simultaneously is determined by the max_replication_slots
GUC. That GUC is not a perfect match to configure this, but there
doesn't seem to be sufficient reason to introduce a separate new one.
Bumps both catversion and wal page magic.
Author: Andres Freund, with contributions from Petr Jelinek and Craig Ringer
Reviewed-By: Heikki Linnakangas, Petr Jelinek, Robert Haas, Steve Singer
Discussion: 20150216002155.GI15326@awork2.anarazel.de,
20140923182422.GA15776@alap3.anarazel.de,
20131114172632.GE7522@alap2.anarazel.de
2015-04-29 19:30:53 +02:00
|
|
|
#include "replication/origin.h"
|
Allow read only connections during recovery, known as Hot Standby.
Enabled by recovery_connections = on (default) and forcing archive recovery using a recovery.conf. Recovery processing now emulates the original transactions as they are replayed, providing full locking and MVCC behaviour for read only queries. Recovery must enter consistent state before connections are allowed, so there is a delay, typically short, before connections succeed. Replay of recovering transactions can conflict and in some cases deadlock with queries during recovery; these result in query cancellation after max_standby_delay seconds have expired. Infrastructure changes have minor effects on normal running, though introduce four new types of WAL record.
New test mode "make standbycheck" allows regression tests of static command behaviour on a standby server while in recovery. Typical and extreme dynamic behaviours have been checked via code inspection and manual testing. Few port specific behaviours have been utilised, though primary testing has been on Linux only so far.
This commit is the basic patch. Additional changes will follow in this release to enhance some aspects of behaviour, notably improved handling of conflicts, deadlock detection and query cancellation. Changes to VACUUM FULL are also required.
Simon Riggs, with significant and lengthy review by Heikki Linnakangas, including streamlined redesign of snapshot creation and two-phase commit.
Important contributions from Florian Pflug, Mark Kirkwood, Merlin Moncure, Greg Stark, Gianni Ciolli, Gabriele Bartolini, Hannu Krosing, Robert Haas, Tatsuo Ishii, Hiroyuki Yamada plus support and feedback from many other community members.
2009-12-19 02:32:45 +01:00
|
|
|
#include "storage/standby.h"
|
2010-02-07 21:48:13 +01:00
|
|
|
#include "utils/relmapper.h"
|
2000-10-21 17:43:36 +02:00
|
|
|
|
2013-02-05 21:21:29 +01:00
|
|
|
/* must be kept in sync with RmgrData definition in xlog_internal.h */
|
2017-02-08 21:45:30 +01:00
|
|
|
#define PG_RMGR(symname,name,redo,desc,identify,startup,cleanup,mask) \
|
|
|
|
{ name, redo, desc, identify, startup, cleanup, mask },
|
2001-08-25 20:52:43 +02:00
|
|
|
|
2004-07-22 00:31:26 +02:00
|
|
|
const RmgrData RmgrTable[RM_MAX_ID + 1] = {
|
2013-02-05 21:21:29 +01:00
|
|
|
#include "access/rmgrlist.h"
|
2000-10-21 17:43:36 +02:00
|
|
|
};
|