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

49.8. ロジカルデコーディングにおける同期レプリケーションのサポート #

<title>Synchronous Replication Support for Logical Decoding</title>

49.8.1. 概要 #

<title>Overview</title>

Logical decoding can be used to build <link linkend="synchronous-replication">synchronous replication</link> solutions with the same user interface as synchronous replication for <link linkend="streaming-replication">streaming replication</link>. To do this, the streaming replication interface (see <xref linkend="logicaldecoding-walsender"/>) must be used to stream out data. Clients have to send <literal>Standby status update (F)</literal> (see <xref linkend="protocol-replication"/>) messages, just like streaming replication clients do. ストリーミングレプリケーションにおける同期レプリケーションと同じユーザインタフェースで、ロジカルデコーディングを使って同期レプリケーションソリューションを構築することができます。 そのためには、ストリーミングレプリケーションインタフェース(49.3参照)を使ってデータをストリーム出力します。 ストリーミングレプリケーションクライアントが行っているのと同じように、状態の更新(55.4参照)メッセージを送信しなければなりません。

注記

A synchronous replica receiving changes via logical decoding will work in the scope of a single database. Since, in contrast to that, <parameter>synchronous_standby_names</parameter> currently is server wide, this means this technique will not work properly if more than one database is actively used. synchronous_standby_namesがサーバ全体に適用されるのに対し、ロジカルデコーディングを通じて変更データを受け取る同期レプリカは、単一のデータベースのスコープの範囲で動作します。 このことにより、複数のデータベースが同時に使用される環境では、ロジカルデコーディングを使った同期レプリケーションはうまく動きません。

49.8.2. 警告 #

<title>Caveats</title>

In synchronous replication setup, a deadlock can happen, if the transaction has locked [user] catalog tables exclusively. See <xref linkend="logicaldecoding-capabilities"/> for information on user catalog tables. This is because logical decoding of transactions can lock catalog tables to access them. To avoid this users must refrain from taking an exclusive lock on [user] catalog tables. This can happen in the following ways: 同期レプリケーション設定では、トランザクションが[user]カタログテーブルを排他的にロックした場合、デッドロックが発生する可能性があります。 ユーザカタログテーブルに関する情報については49.6.2を参照してください。 これは、トランザクションの論理的なデコードがカタログテーブルをロックしてアクセスできるためです。 これを回避するために、ユーザは[user]カタログテーブルに対する排他ロックの取得を控える必要があります。 これは以下の方法で発生します。

  • Issuing an explicit <command>LOCK</command> on <structname>pg_class</structname> in a transaction. トランザクションのpg_classに対する明示的なLOCKの発行。

  • Perform <command>CLUSTER</command> on <structname>pg_class</structname> in a transaction. トランザクション内のpg_classに対してCLUSTERを実行。

  • <command>PREPARE TRANSACTION</command> after <command>LOCK</command> command on <structname>pg_class</structname> and allow logical decoding of two-phase transactions. pg_class上のLOCKコマンドの後にPREPARE TRANSACTIONを実行し、2相トランザクションのロジカルデコーディングを可能にする。

  • <command>PREPARE TRANSACTION</command> after <command>CLUSTER</command> command on <structname>pg_trigger</structname> and allow logical decoding of two-phase transactions. This will lead to deadlock only when published table have a trigger. pg_trigger上のCLUSTERコマンドの後にPREPARE TRANSACTIONを実行し、2相トランザクションのロジカルデコーディングを可能にする。 これにより、発行されたテーブルにトリガがある場合にのみデッドロックが発生します。

  • Executing <command>TRUNCATE</command> on [user] catalog table in a transaction. トランザクションの[user]カタログテーブルに対してTRUNCATEを実行。

Note that these commands that can cause deadlock apply to not only explicitly indicated system catalog tables above but also to any other [user] catalog table. デッドロックの原因となるこれらのコマンドは、上記の明示的に指定されたシステムカタログテーブルだけでなく、他の[user]カタログテーブルにも適用されることに注意してください。