Skip to content

Commit 22f7e61

Browse files
author
Amit Kapila
committed
Clean-ups for 776621a and 7329240.
Following are a few clean-ups related to failover option support in slots: 1. Improve the documentation in create_subscription.sgml. 2. Remove the spurious blank line in subscriptioncmds.c. 3. Remove the NOTICE for alter_replication_slot in subscriptioncmds.c as we would sometimes print it even when nothing has changed. One can find the change by enabling log_replication_commands on the publisher. 4. Optimize ReplicationSlotAlter() function to prevent disk flushing when the slot's data remains unchanged. Author: Hou Zhijie Reviewed-by: Amit Kapila Discussion: https://postgr.es/m/514f6f2f-6833-4539-39f1-96cd1e011f23@enterprisedb.com Discussion: https://postgr.es/m/OS0PR01MB57164904651FB588A518E98894472@OS0PR01MB5716.jpnprd01.prod.outlook.com
1 parent b9d6038 commit 22f7e61

File tree

4 files changed

+12
-19
lines changed

4 files changed

+12
-19
lines changed

doc/src/sgml/ref/create_subscription.sgml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -117,9 +117,8 @@ CREATE SUBSCRIPTION <replaceable class="parameter">subscription_name</replaceabl
117117
command should connect to the publisher at all. The default
118118
is <literal>true</literal>. Setting this to
119119
<literal>false</literal> will force the values of
120-
<literal>create_slot</literal>, <literal>enabled</literal>,
121-
<literal>copy_data</literal>, and <literal>failover</literal>
122-
to <literal>false</literal>.
120+
<literal>create_slot</literal>, <literal>enabled</literal> and
121+
<literal>copy_data</literal> to <literal>false</literal>.
123122
(You cannot combine setting <literal>connect</literal>
124123
to <literal>false</literal> with
125124
setting <literal>create_slot</literal>, <literal>enabled</literal>,

doc/src/sgml/ref/pg_dump.sgml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1591,9 +1591,7 @@ CREATE DATABASE foo WITH TEMPLATE template0;
15911591
information might have to be changed. If the subscription needs to
15921592
be enabled for
15931593
<link linkend="sql-createsubscription-params-with-failover"><literal>failover</literal></link>,
1594-
then same needs to be done by executing
1595-
<link linkend="sql-altersubscription-params-set">
1596-
<literal>ALTER SUBSCRIPTION ... SET (failover = true)</literal></link>
1594+
execute <link linkend="sql-altersubscription-params-set"><literal>ALTER SUBSCRIPTION ... SET (failover = true)</literal></link>
15971595
after the slot has been created. It might also be appropriate to
15981596
truncate the target tables before initiating a new full table copy. If users
15991597
intend to copy initial data during refresh they must create the slot with

src/backend/commands/subscriptioncmds.c

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,6 @@
7373
#define SUBOPT_LSN 0x00004000
7474
#define SUBOPT_ORIGIN 0x00008000
7575

76-
7776
/* check if the 'val' has 'bits' set */
7877
#define IsSet(val, bits) (((val) & (bits)) == (bits))
7978

@@ -852,9 +851,6 @@ CreateSubscription(ParseState *pstate, CreateSubscriptionStmt *stmt,
852851
(opts.failover || walrcv_server_version(wrconn) >= 170000))
853852
{
854853
walrcv_alter_slot(wrconn, opts.slot_name, opts.failover);
855-
ereport(NOTICE,
856-
(errmsg("changed the failover state of replication slot \"%s\" on publisher to %s",
857-
opts.slot_name, opts.failover ? "true" : "false")));
858854
}
859855
}
860856
PG_FINALLY();
@@ -1547,10 +1543,6 @@ AlterSubscription(ParseState *pstate, AlterSubscriptionStmt *stmt,
15471543
PG_TRY();
15481544
{
15491545
walrcv_alter_slot(wrconn, sub->slotname, opts.failover);
1550-
1551-
ereport(NOTICE,
1552-
(errmsg("changed the failover state of replication slot \"%s\" on publisher to %s",
1553-
sub->slotname, opts.failover ? "true" : "false")));
15541546
}
15551547
PG_FINALLY();
15561548
{

src/backend/replication/slot.c

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -696,12 +696,16 @@ ReplicationSlotAlter(const char *name, bool failover)
696696
errmsg("cannot use %s with a physical replication slot",
697697
"ALTER_REPLICATION_SLOT"));
698698

699-
SpinLockAcquire(&MyReplicationSlot->mutex);
700-
MyReplicationSlot->data.failover = failover;
701-
SpinLockRelease(&MyReplicationSlot->mutex);
699+
if (MyReplicationSlot->data.failover != failover)
700+
{
701+
SpinLockAcquire(&MyReplicationSlot->mutex);
702+
MyReplicationSlot->data.failover = failover;
703+
SpinLockRelease(&MyReplicationSlot->mutex);
704+
705+
ReplicationSlotMarkDirty();
706+
ReplicationSlotSave();
707+
}
702708

703-
ReplicationSlotMarkDirty();
704-
ReplicationSlotSave();
705709
ReplicationSlotRelease();
706710
}
707711

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy