From: | Andres Freund <andres(at)anarazel(dot)de> |
---|---|
To: | pgsql-committers(at)postgresql(dot)org |
Subject: | pgsql: Introduce replication progress tracking infrastructure. |
Date: | 2015-04-29 17:37:09 |
Message-ID: | E1YnVv3-0006Vm-3S@gemulon.postgresql.org |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-committers |
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(dot)GI15326(at)awork2(dot)anarazel(dot)de,
20140923182422(dot)GA15776(at)alap3(dot)anarazel(dot)de,
20131114172632(dot)GE7522(at)alap2(dot)anarazel(dot)de
Branch
------
master
Details
-------
http://git.postgresql.org/pg/commitdiff/5aa2350426c4fdb3d04568b65aadac397012bbcb
Modified Files
--------------
contrib/test_decoding/Makefile | 3 +-
contrib/test_decoding/expected/replorigin.out | 141 +++
contrib/test_decoding/sql/replorigin.sql | 64 +
contrib/test_decoding/test_decoding.c | 28 +
doc/src/sgml/catalogs.sgml | 123 ++
doc/src/sgml/filelist.sgml | 1 +
doc/src/sgml/func.sgml | 201 ++-
doc/src/sgml/logicaldecoding.sgml | 35 +-
doc/src/sgml/postgres.sgml | 1 +
doc/src/sgml/replication-origins.sgml | 93 ++
src/backend/access/heap/heapam.c | 19 +
src/backend/access/rmgrdesc/Makefile | 4 +-
src/backend/access/rmgrdesc/replorigindesc.c | 61 +
src/backend/access/rmgrdesc/xactdesc.c | 24 +-
src/backend/access/transam/commit_ts.c | 53 +-
src/backend/access/transam/rmgr.c | 1 +
src/backend/access/transam/xact.c | 76 +-
src/backend/access/transam/xlog.c | 8 +
src/backend/access/transam/xloginsert.c | 27 +-
src/backend/access/transam/xlogreader.c | 6 +
src/backend/catalog/Makefile | 2 +-
src/backend/catalog/catalog.c | 8 +-
src/backend/catalog/system_views.sql | 7 +
src/backend/replication/logical/Makefile | 3 +-
src/backend/replication/logical/decode.c | 49 +-
src/backend/replication/logical/logical.c | 29 +
src/backend/replication/logical/origin.c | 1485 +++++++++++++++++++++++
src/backend/replication/logical/reorderbuffer.c | 5 +-
src/backend/storage/ipc/ipci.c | 3 +
src/backend/utils/cache/syscache.c | 23 +
src/bin/pg_resetxlog/pg_resetxlog.c | 3 +
src/include/access/commit_ts.h | 14 +-
src/include/access/rmgrlist.h | 1 +
src/include/access/xact.h | 11 +
src/include/access/xlog.h | 1 +
src/include/access/xlog_internal.h | 2 +-
src/include/access/xlogdefs.h | 6 +
src/include/access/xloginsert.h | 1 +
src/include/access/xlogreader.h | 3 +
src/include/access/xlogrecord.h | 1 +
src/include/catalog/catversion.h | 2 +-
src/include/catalog/indexing.h | 6 +
src/include/catalog/pg_proc.h | 36 +
src/include/catalog/pg_replication_origin.h | 70 ++
src/include/replication/logical.h | 2 +
src/include/replication/origin.h | 86 ++
src/include/replication/output_plugin.h | 8 +
src/include/replication/reorderbuffer.h | 8 +-
src/include/storage/lwlock.h | 3 +-
src/include/utils/syscache.h | 2 +
src/test/regress/expected/rules.out | 5 +
src/test/regress/expected/sanity_check.out | 1 +
52 files changed, 2766 insertions(+), 89 deletions(-)
From | Date | Subject | |
---|---|---|---|
Next Message | Andrew Dunstan | 2015-04-29 17:54:36 | pgsql: Enable transforms tests for python 2 on MSVC builds |
Previous Message | Robert Haas | 2015-04-29 16:59:43 | pgsql: psql: Improve tab completion for ALTER FOREIGN TABLE. |