バージョンごとのドキュメント一覧

29.3. Logical Replication Failover #

To allow subscriber nodes to continue replicating data from the publisher node even when the publisher node goes down, there must be a physical standby corresponding to the publisher node. The logical slots on the primary server corresponding to the subscriptions can be synchronized to the standby server by specifying <literal>failover = true</literal> when creating subscriptions. See <xref linkend="logicaldecoding-replication-slots-synchronization"/> for details. Enabling the <link linkend="sql-createsubscription-params-with-failover"><literal>failover</literal></link> parameter ensures a seamless transition of those subscriptions after the standby is promoted. They can continue subscribing to publications on the new primary server without losing data. Note that in the case of asynchronous replication, there remains a risk of data loss for transactions committed on the former primary server but have yet to be replicated to the new primary server. 《機械翻訳》サブスクライバーノードがダウンに移動した場合でも、パブリッシャーノードからのデータの複製をパブリッシャーノードが継続できるようにするには、パブリッシャーノードに対応する物理的スタンバイが必要です。 定期購読/購買の作成時にロジカル=プライマリーサーバを指定すると、定期購読/購買に対応するスタンバイサーバのフェイルオーバースロットを真に同期化できます。 詳細については、47.2.3を参照してください。 フェイルオーバーパラメータを有効にすると、スタンバイが昇格した後、これらのサブスクリプションがシームレスに移行されます。 彼らは、データを失うことなく、新しいプライマリーサーバの出版物の購読を続けることができる。 非同期レプリケーションのケースには、旧プライマリーサーバで行われた取引のためのデータロスのリスクが残っているが、新プライマリーサーバにはまだ複製されていないノート。

Because the slot synchronization logic copies asynchronously, it is necessary to confirm that replication slots have been synced to the standby server before the failover happens. To ensure a successful failover, the standby server must be ahead of the subscriber. This can be achieved by configuring <link linkend="guc-standby-slot-names"><varname>standby_slot_names</varname></link>. 《機械翻訳》スロットの同期化ロジックは非同期的にコピーされるため、レプリケーションスロットがフェイルオーバーが発生するスタンバイサーバ前に同期化されていることを確認する必要があります。 フェイルオーバーを正常に保証するには、スタンバイサーバがサブスクライバーより前にある必要があります。 これは、スタンバイ_スロット_namesを設定することによって実現できます。

To confirm that the standby server is indeed ready for failover, follow these steps to verify that all necessary logical replication slots have been synchronized to the standby server: 《機械翻訳》スタンバイサーバが実際にフェイルオーバーの準備ができていることを確認するには、次の手順に従って、必要なすべてのロジカルレプリケーションスロットがスタンバイサーバに同期されていることを確認します。

  1. On the subscriber node, use the following SQL to identify which slots should be synced to the standby that we plan to promote. This query will return the relevant replication slots, including the main slots and table synchronization slots associated with the failover-enabled subscriptions. 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 as they will either be dropped or re-created on the new primary server in those cases. 《機械翻訳》サブスクライバーノードでは、次のSQLを使用して、プランからプロモートまでのスタンバイに同期するスロットを特定します。 このクエリは、レプリケーション対応のサブスクリプションに関連付けられたメインスロットおよびテーブル同期化スロットを含む、関連するフェイルオーバースロットを結果します。 ノートコピーが完了した場合にのみ、テーブル同期スロットをスタンバイサーバに同期する必要があるテーブル(51.55を参照)。 テーブルの同期スロットが他のシナリオで同期されることを保証する必要はありません。 このような場合は、新しいプライマリーサーバでドロップされるか、再作成されます。

    test_sub=# SELECT
                   array_agg(slot_name) AS slots
               FROM
               ((
                   SELECT r.srsubid AS subid, CONCAT('pg_', srsubid, '_sync_', srrelid, '_', ctl.system_identifier) AS slot_name
                   FROM pg_control_system() ctl, pg_subscription_rel r, pg_subscription s
                   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
    -------
     {sub1,sub2,sub3}
    (1 row)
    
  2. Check that the logical replication slots identified above exist on the standby server and are ready for failover. 《機械翻訳》上記のチェックスロットがスタンバイサーバに存在し、フェイルオーバーの準備ができているロジカルレプリケーション。

    test_standby=# SELECT slot_name, (synced AND NOT temporary AND NOT conflicting) AS failover_ready
                   FROM pg_replication_slots
                   WHERE slot_name IN ('sub1','sub2','sub3');
      slot_name  | failover_ready
    -------------+----------------
      sub1       | t
      sub2       | t
      sub3       | t
    (3 rows)
    

If all the slots are present on the standby server and the result (<literal>failover_ready</literal>) of the above SQL query is true, then existing subscriptions can continue subscribing to publications now on the new primary server without losing data. 《機械翻訳》すべてのスロットがスタンバイサーバに存在し、上記のフェイルオーバークエリの結果真_ready)がである場合、既存のサブスクリプションは、データを失うことなく、新しいプライマリーサーバでパブリケーションのサブスクリプションを継続できます。 SQL