pgsql: Enable logical slots to follow timeline switches

From: Alvaro Herrera <alvherre(at)alvh(dot)no-ip(dot)org>
To: pgsql-committers(at)postgresql(dot)org
Subject: pgsql: Enable logical slots to follow timeline switches
Date: 2016-03-30 23:09:03
Message-ID: E1alPEV-0008SA-Q1@gemulon.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers pgsql-hackers

Enable logical slots to follow timeline switches

When decoding from a logical slot, it's necessary for xlog reading to be
able to read xlog from historical (i.e. not current) timelines;
otherwise, decoding fails after failover, because the archives are in
the historical timeline. This is required to make "failover logical
slots" possible; it currently has no other use, although theoretically
it could be used by an extension that creates a slot on a standby and
continues to replay from the slot when the standby is promoted.

This commit includes a module in src/test/modules with functions to
manipulate the slots (which is not otherwise possible in SQL code) in
order to enable testing, and a new test in src/test/recovery to ensure
that the behavior is as expected.

Author: Craig Ringer
Reviewed-By: Oleksii Kliukin, Andres Freund, Petr Jelínek

Branch
------
master

Details
-------
http://git.postgresql.org/pg/commitdiff/24c5f1a103ce6656a5cb430d9a996c34e61ab2a5

Modified Files
--------------
src/backend/access/transam/xlogreader.c | 9 +
src/backend/access/transam/xlogutils.c | 244 +++++++++++++++--
src/backend/replication/logical/logicalfuncs.c | 17 +-
src/include/access/xlogreader.h | 18 ++
src/test/modules/Makefile | 1 +
src/test/modules/test_slot_timelines/.gitignore | 3 +
src/test/modules/test_slot_timelines/Makefile | 22 ++
src/test/modules/test_slot_timelines/README | 19 ++
.../expected/load_extension.out | 19 ++
.../test_slot_timelines/sql/load_extension.sql | 7 +
.../test_slot_timelines--1.0.sql | 16 ++
.../test_slot_timelines/test_slot_timelines.c | 133 +++++++++
.../test_slot_timelines/test_slot_timelines.conf | 2 +
.../test_slot_timelines.control | 5 +
src/test/recovery/Makefile | 2 +
.../recovery/t/006_logical_decoding_timelines.pl | 304 +++++++++++++++++++++
16 files changed, 790 insertions(+), 31 deletions(-)

Responses

Browse pgsql-committers by date

  From Date Subject
Next Message Tom Lane 2016-03-30 23:39:06 Re: pgsql: Enable logical slots to follow timeline switches
Previous Message Alvaro Herrera 2016-03-30 21:57:21 pgsql: XLogReader general code cleanup

Browse pgsql-hackers by date

  From Date Subject
Next Message Andres Freund 2016-03-30 23:09:14 Re: Speed up Clog Access by increasing CLOG buffers
Previous Message Vitaly Burovoy 2016-03-30 23:06:23 Re: [PATCH] Supporting +-Infinity values by to_timestamp(float8)