mirror of
				https://github.com/postgres/postgres.git
				synced 2025-11-03 09:13:20 +03:00 
			
		
		
		
	Doc: Fix the mistakes in the subscription's failover option.
The documentation incorrectly stated that users could not alter the subscription's failover option when the two-phase commit is enabled. The steps to confirm that the standby server is ready for failover were incorrect. Author: Shveta Malik, Hou Zhijie Reviewed-by: Amit Kapila Discussion: https://postgr.es/m/OS0PR01MB571657B72F8D75BD858DCCE394AD2@OS0PR01MB5716.jpnprd01.prod.outlook.com Discussion: https://postgr.es/m/CAJpy0uBBk+OZXXqQ00Gai09XR+mDi2=9sMBYY0F+BedoFivaMA@mail.gmail.com
This commit is contained in:
		@@ -725,32 +725,45 @@ ALTER SUBSCRIPTION
 | 
				
			|||||||
  <procedure>
 | 
					  <procedure>
 | 
				
			||||||
   <step performance="required">
 | 
					   <step performance="required">
 | 
				
			||||||
    <para>
 | 
					    <para>
 | 
				
			||||||
     On the subscriber node, use the following SQL to identify which slots
 | 
					     On the subscriber node, use the following SQL to identify which replication
 | 
				
			||||||
     should be synced to the standby that we plan to promote. This query will
 | 
					     slots should be synced to the standby that we plan to promote. This query
 | 
				
			||||||
     return the relevant replication slots, including the main slots and table
 | 
					     will return the relevant replication slots associated with the
 | 
				
			||||||
     synchronization slots associated with the failover-enabled subscriptions.
 | 
					     failover-enabled subscriptions.
 | 
				
			||||||
     Note that the table sync slot should be synced to the standby server only
 | 
					<programlisting>
 | 
				
			||||||
     if the table copy is finished (See <xref linkend="catalog-pg-subscription-rel"/>).
 | 
					test_sub=# SELECT
 | 
				
			||||||
 | 
					               array_agg(quote_literal(s.subslotname)) AS slots
 | 
				
			||||||
 | 
					           FROM  pg_subscription s
 | 
				
			||||||
 | 
					           WHERE s.subfailover AND
 | 
				
			||||||
 | 
					                 s.subslotname IS NOT NULL;
 | 
				
			||||||
 | 
					 slots
 | 
				
			||||||
 | 
					-------
 | 
				
			||||||
 | 
					 {'sub1','sub2','sub3'}
 | 
				
			||||||
 | 
					(1 row)
 | 
				
			||||||
 | 
					</programlisting></para>
 | 
				
			||||||
 | 
					   </step>
 | 
				
			||||||
 | 
					   <step performance="required">
 | 
				
			||||||
 | 
					    <para>
 | 
				
			||||||
 | 
					     On the subscriber node, use the following SQL to identify which table
 | 
				
			||||||
 | 
					     synchronization slots should be synced to the standby that we plan to promote.
 | 
				
			||||||
 | 
					     This query needs to be run on each database that includes the failover-enabled
 | 
				
			||||||
 | 
					     subscription(s). Note that the table sync slot should be synced to the standby
 | 
				
			||||||
 | 
					     server only if the table copy is finished
 | 
				
			||||||
 | 
					     (See <xref linkend="catalog-pg-subscription-rel"/>).
 | 
				
			||||||
     We don't need to ensure that the table sync slots are synced in other scenarios
 | 
					     We don't need to ensure that the table sync slots are synced in other scenarios
 | 
				
			||||||
     as they will either be dropped or re-created on the new primary server in those
 | 
					     as they will either be dropped or re-created on the new primary server in those
 | 
				
			||||||
     cases.
 | 
					     cases.
 | 
				
			||||||
<programlisting>
 | 
					<programlisting>
 | 
				
			||||||
test_sub=# SELECT
 | 
					test_sub=# SELECT
 | 
				
			||||||
               array_agg(slot_name) AS slots
 | 
					               array_agg(quote_literal(slot_name)) AS slots
 | 
				
			||||||
           FROM
 | 
					           FROM
 | 
				
			||||||
           ((
 | 
					           (
 | 
				
			||||||
               SELECT r.srsubid AS subid, CONCAT('pg_', srsubid, '_sync_', srrelid, '_', ctl.system_identifier) AS slot_name
 | 
					               SELECT CONCAT('pg_', srsubid, '_sync_', srrelid, '_', ctl.system_identifier) AS slot_name
 | 
				
			||||||
               FROM pg_control_system() ctl, pg_subscription_rel r, pg_subscription s
 | 
					               FROM pg_control_system() ctl, pg_subscription_rel r, pg_subscription s
 | 
				
			||||||
               WHERE r.srsubstate = 'f' AND s.oid = r.srsubid AND s.subfailover
 | 
					               WHERE r.srsubstate = 'f' AND s.oid = r.srsubid AND s.subfailover
 | 
				
			||||||
           ) UNION (
 | 
					           );
 | 
				
			||||||
               SELECT s.oid AS subid, s.subslotname as slot_name
 | 
					 | 
				
			||||||
               FROM pg_subscription s
 | 
					 | 
				
			||||||
               WHERE s.subfailover
 | 
					 | 
				
			||||||
           ))
 | 
					 | 
				
			||||||
           WHERE slot_name IS NOT NULL;
 | 
					 | 
				
			||||||
 slots
 | 
					 slots
 | 
				
			||||||
-------
 | 
					-------
 | 
				
			||||||
 {sub1,sub2,sub3}
 | 
					 {'pg_16394_sync_16385_7394666715149055164'}
 | 
				
			||||||
(1 row)
 | 
					(1 row)
 | 
				
			||||||
</programlisting></para>
 | 
					</programlisting></para>
 | 
				
			||||||
   </step>
 | 
					   </step>
 | 
				
			||||||
@@ -761,13 +774,15 @@ test_sub=# SELECT
 | 
				
			|||||||
<programlisting>
 | 
					<programlisting>
 | 
				
			||||||
test_standby=# SELECT slot_name, (synced AND NOT temporary AND NOT conflicting) AS failover_ready
 | 
					test_standby=# SELECT slot_name, (synced AND NOT temporary AND NOT conflicting) AS failover_ready
 | 
				
			||||||
               FROM pg_replication_slots
 | 
					               FROM pg_replication_slots
 | 
				
			||||||
               WHERE slot_name IN ('sub1','sub2','sub3');
 | 
					               WHERE slot_name IN
 | 
				
			||||||
 | 
					                   ('sub1','sub2','sub3', 'pg_16394_sync_16385_7394666715149055164');
 | 
				
			||||||
  slot_name                                 | failover_ready
 | 
					  slot_name                                 | failover_ready
 | 
				
			||||||
-------------+----------------
 | 
					--------------------------------------------+----------------
 | 
				
			||||||
  sub1                                      | t
 | 
					  sub1                                      | t
 | 
				
			||||||
  sub2                                      | t
 | 
					  sub2                                      | t
 | 
				
			||||||
  sub3                                      | t
 | 
					  sub3                                      | t
 | 
				
			||||||
(3 rows)
 | 
					  pg_16394_sync_16385_7394666715149055164   | t
 | 
				
			||||||
 | 
					(4 rows)
 | 
				
			||||||
</programlisting></para>
 | 
					</programlisting></para>
 | 
				
			||||||
    </step>
 | 
					    </step>
 | 
				
			||||||
  </procedure>
 | 
					  </procedure>
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -71,8 +71,13 @@ ALTER SUBSCRIPTION <replaceable class="parameter">name</replaceable> RENAME TO <
 | 
				
			|||||||
   with <literal>refresh</literal> option as <literal>true</literal> and
 | 
					   with <literal>refresh</literal> option as <literal>true</literal> and
 | 
				
			||||||
   <command>ALTER SUBSCRIPTION ... SET (failover = true|false)</command>
 | 
					   <command>ALTER SUBSCRIPTION ... SET (failover = true|false)</command>
 | 
				
			||||||
   cannot be executed inside a transaction block.
 | 
					   cannot be executed inside a transaction block.
 | 
				
			||||||
 | 
					  </para>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
   These commands also cannot be executed when the subscription has
 | 
					  <para>
 | 
				
			||||||
 | 
					   Commands <command>ALTER SUBSCRIPTION ... REFRESH PUBLICATION</command> and
 | 
				
			||||||
 | 
					   <command>ALTER SUBSCRIPTION ... {SET|ADD|DROP} PUBLICATION ...</command>
 | 
				
			||||||
 | 
					   with <literal>refresh</literal> option as <literal>true</literal> also cannot
 | 
				
			||||||
 | 
					   be executed when the subscription has
 | 
				
			||||||
   <link linkend="sql-createsubscription-params-with-two-phase"><literal>two_phase</literal></link>
 | 
					   <link linkend="sql-createsubscription-params-with-two-phase"><literal>two_phase</literal></link>
 | 
				
			||||||
   commit enabled, unless
 | 
					   commit enabled, unless
 | 
				
			||||||
   <link linkend="sql-createsubscription-params-with-copy-data"><literal>copy_data</literal></link>
 | 
					   <link linkend="sql-createsubscription-params-with-copy-data"><literal>copy_data</literal></link>
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user