On 20/04/17 23:30, Peter Eisentraut wrote: > On 4/20/17 10:19, Petr Jelinek wrote: >> Hmm well since this only affects the synchronization of table >> states/names, I guess we could just simply do that before we create the >> slot as there is no expectancy of consistency between slot and the table >> list snapshot. > > I suppose that wouldn't hurt. > > Prior to the table sync patch, a missing target relation would just show > up as an error later on in the logs. So having the error sooner > actually seems like a good change. >
Very simple patch to make. -- Petr Jelinek http://www.2ndQuadrant.com/ PostgreSQL Development, 24x7 Support, Training & Services
From c86411521694fd2729a81ebaa09c98e346886b59 Mon Sep 17 00:00:00 2001 From: Petr Jelinek <pjmo...@pjmodos.net> Date: Fri, 21 Apr 2017 04:31:58 +0200 Subject: [PATCH] Synchronize table list before creating slot in CREATE SUBSCRIPTION This way the failure to synchronize the table list will not leave an unused slot on publisher. --- src/backend/commands/subscriptioncmds.c | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/src/backend/commands/subscriptioncmds.c b/src/backend/commands/subscriptioncmds.c index 35dccbc..c29a57e 100644 --- a/src/backend/commands/subscriptioncmds.c +++ b/src/backend/commands/subscriptioncmds.c @@ -395,20 +395,6 @@ CreateSubscription(CreateSubscriptionStmt *stmt, bool isTopLevel) PG_TRY(); { /* - * If requested, create permanent slot for the subscription. - * We won't use the initial snapshot for anything, so no need - * to export it. - */ - if (create_slot) - { - walrcv_create_slot(wrconn, slotname, false, - CRS_NOEXPORT_SNAPSHOT, &lsn); - ereport(NOTICE, - (errmsg("created replication slot \"%s\" on publisher", - slotname))); - } - - /* * Set sync state based on if we were asked to do data copy or * not. */ @@ -432,6 +418,20 @@ CreateSubscription(CreateSubscriptionStmt *stmt, bool isTopLevel) ereport(NOTICE, (errmsg("synchronized table states"))); + + /* + * If requested, create permanent slot for the subscription. + * We won't use the initial snapshot for anything, so no need + * to export it. + */ + if (create_slot) + { + walrcv_create_slot(wrconn, slotname, false, + CRS_NOEXPORT_SNAPSHOT, &lsn); + ereport(NOTICE, + (errmsg("created replication slot \"%s\" on publisher", + slotname))); + } } PG_CATCH(); { -- 2.7.4
-- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers