Skip to content

Commit 665d1fa

Browse files
committed
Logical replication
- Add PUBLICATION catalogs and DDL - Add SUBSCRIPTION catalog and DDL - Define logical replication protocol and output plugin - Add logical replication workers From: Petr Jelinek <petr@2ndquadrant.com> Reviewed-by: Steve Singer <steve@ssinger.info> Reviewed-by: Andres Freund <andres@anarazel.de> Reviewed-by: Erik Rijkers <er@xs4all.nl> Reviewed-by: Peter Eisentraut <peter.eisentraut@2ndquadrant.com>
1 parent ba61a04 commit 665d1fa

File tree

119 files changed

+13354
-95
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

119 files changed

+13354
-95
lines changed

doc/src/sgml/catalogs.sgml

+309
Original file line numberDiff line numberDiff line change
@@ -240,6 +240,16 @@
240240
<entry>functions and procedures</entry>
241241
</row>
242242

243+
<row>
244+
<entry><link linkend="catalog-pg-publication"><structname>pg_publication</structname></link></entry>
245+
<entry>publications for logical replication</entry>
246+
</row>
247+
248+
<row>
249+
<entry><link linkend="catalog-pg-publication-rel"><structname>pg_publication_rel</structname></link></entry>
250+
<entry>relation to publication mapping</entry>
251+
</row>
252+
243253
<row>
244254
<entry><link linkend="catalog-pg-range"><structname>pg_range</structname></link></entry>
245255
<entry>information about range types</entry>
@@ -285,6 +295,11 @@
285295
<entry>planner statistics</entry>
286296
</row>
287297

298+
<row>
299+
<entry><link linkend="catalog-pg-subscription"><structname>pg_subscription</structname></link></entry>
300+
<entry>logical replication subscriptions</entry>
301+
</row>
302+
288303
<row>
289304
<entry><link linkend="catalog-pg-tablespace"><structname>pg_tablespace</structname></link></entry>
290305
<entry>tablespaces within this database cluster</entry>
@@ -5271,6 +5286,137 @@
52715286

52725287
</sect1>
52735288

5289+
<sect1 id="catalog-pg-publication">
5290+
<title><structname>pg_publication</structname></title>
5291+
5292+
<indexterm zone="catalog-pg-publication">
5293+
<primary>pg_publication</primary>
5294+
</indexterm>
5295+
5296+
<para>
5297+
The catalog <structname>pg_publication</structname> contains all
5298+
publications created in the database. For more on publications see
5299+
<xref linkend="logical-replication-publication">.
5300+
</para>
5301+
5302+
<table>
5303+
<title><structname>pg_publication</structname> Columns</title>
5304+
5305+
<tgroup cols="4">
5306+
<thead>
5307+
<row>
5308+
<entry>Name</entry>
5309+
<entry>Type</entry>
5310+
<entry>References</entry>
5311+
<entry>Description</entry>
5312+
</row>
5313+
</thead>
5314+
5315+
<tbody>
5316+
<row>
5317+
<entry><structfield>oid</structfield></entry>
5318+
<entry><type>oid</type></entry>
5319+
<entry></entry>
5320+
<entry>Row identifier (hidden attribute; must be explicitly selected)</entry>
5321+
</row>
5322+
5323+
<row>
5324+
<entry><structfield>pubname</structfield></entry>
5325+
<entry><type>Name</type></entry>
5326+
<entry></entry>
5327+
<entry>Name of the publication</entry>
5328+
</row>
5329+
5330+
<row>
5331+
<entry><structfield>pubowner</structfield></entry>
5332+
<entry><type>oid</type></entry>
5333+
<entry><literal><link linkend="catalog-pg-authid"><structname>pg_authid</structname></link>.oid</literal></entry>
5334+
<entry>Owner of the publication</entry>
5335+
</row>
5336+
5337+
<row>
5338+
<entry><structfield>puballtables</structfield></entry>
5339+
<entry><type>bool</type></entry>
5340+
<entry></entry>
5341+
<entry>If true, this publication automatically includes all tables
5342+
in the database, including any that will be created in the future.
5343+
</entry>
5344+
</row>
5345+
5346+
<row>
5347+
<entry><structfield>pubinsert</structfield></entry>
5348+
<entry><type>bool</type></entry>
5349+
<entry></entry>
5350+
<entry>If true, <command>INSERT</command> operations are replicated for
5351+
tables in the publication.</entry>
5352+
</row>
5353+
5354+
<row>
5355+
<entry><structfield>pubupdate</structfield></entry>
5356+
<entry><type>bool</type></entry>
5357+
<entry></entry>
5358+
<entry>If true, <command>UPDATE</command> operations are replicated for
5359+
tables in the publication.</entry>
5360+
</row>
5361+
5362+
<row>
5363+
<entry><structfield>pubdelete</structfield></entry>
5364+
<entry><type>bool</type></entry>
5365+
<entry></entry>
5366+
<entry>If true, <command>DELETE</command> operations are replicated for
5367+
tables in the publication.</entry>
5368+
</row>
5369+
</tbody>
5370+
</tgroup>
5371+
</table>
5372+
</sect1>
5373+
5374+
<sect1 id="catalog-pg-publication-rel">
5375+
<title><structname>pg_publication_rel</structname></title>
5376+
5377+
<indexterm zone="catalog-pg-publication-rel">
5378+
<primary>pg_publication_rel</primary>
5379+
</indexterm>
5380+
5381+
<para>
5382+
The catalog <structname>pg_publication_rel</structname> contains the
5383+
mapping between relations and publications in the database. This is a
5384+
many-to-many mapping. See also <xref linkend="view-pg-publication-tables">
5385+
for a more user-friendly view of this information.
5386+
</para>
5387+
5388+
<table>
5389+
<title><structname>pg_publication_rel</structname> Columns</title>
5390+
5391+
<tgroup cols="4">
5392+
<thead>
5393+
<row>
5394+
<entry>Name</entry>
5395+
<entry>Type</entry>
5396+
<entry>References</entry>
5397+
<entry>Description</entry>
5398+
</row>
5399+
</thead>
5400+
5401+
<tbody>
5402+
<row>
5403+
<entry><structfield>prpubid</structfield></entry>
5404+
<entry><type>oid</type></entry>
5405+
<entry><literal><link linkend="catalog-pg-publication"><structname>pg_publication</structname></link>.oid</literal></entry>
5406+
<entry>Reference to publication</entry>
5407+
</row>
5408+
5409+
<row>
5410+
<entry><structfield>prrelid</structfield></entry>
5411+
<entry><type>oid</type></entry>
5412+
<entry><literal><link linkend="catalog-pg-class"><structname>pg_class</structname></link>.oid</literal></entry>
5413+
<entry>Reference to relation</entry>
5414+
</row>
5415+
</tbody>
5416+
</tgroup>
5417+
</table>
5418+
</sect1>
5419+
52745420
<sect1 id="catalog-pg-range">
52755421
<title><structname>pg_range</structname></title>
52765422

@@ -6150,6 +6296,109 @@
61506296

61516297
</sect1>
61526298

6299+
<sect1 id="catalog-pg-subscription">
6300+
<title><structname>pg_subscription</structname></title>
6301+
6302+
<indexterm zone="catalog-pg-subscription">
6303+
<primary>pg_subscription</primary>
6304+
</indexterm>
6305+
6306+
<para>
6307+
The catalog <structname>pg_subscription</structname> contains all existing
6308+
logical replication subscriptions. For more information about logical
6309+
replication see <xref linkend="logical-replication">.
6310+
</para>
6311+
6312+
<para>
6313+
Unlike most system catalogs, <structname>pg_subscription</structname> is
6314+
shared across all databases of a cluster: There is only one copy
6315+
of <structname>pg_subscription</structname> per cluster, not one per
6316+
database.
6317+
</para>
6318+
6319+
<para>
6320+
Access to this catalog is restricted from normal users. Normal users can
6321+
use the view <xref linkend="pg-stat-subscription"> to get some information
6322+
about subscriptions.
6323+
</para>
6324+
6325+
<table>
6326+
<title><structname>pg_subscription</structname> Columns</title>
6327+
6328+
<tgroup cols="4">
6329+
<thead>
6330+
<row>
6331+
<entry>Name</entry>
6332+
<entry>Type</entry>
6333+
<entry>References</entry>
6334+
<entry>Description</entry>
6335+
</row>
6336+
</thead>
6337+
6338+
<tbody>
6339+
<row>
6340+
<entry><structfield>oid</structfield></entry>
6341+
<entry><type>oid</type></entry>
6342+
<entry></entry>
6343+
<entry>Row identifier (hidden attribute; must be explicitly selected)</entry>
6344+
</row>
6345+
6346+
<row>
6347+
<entry><structfield>subdbid</structfield></entry>
6348+
<entry><type>oid</type></entry>
6349+
<entry><literal><link linkend="catalog-pg-database"><structname>pg_database</structname></link>.oid</literal></entry>
6350+
<entry>OID of the database which the subscription resides in</entry>
6351+
</row>
6352+
6353+
<row>
6354+
<entry><structfield>subname</structfield></entry>
6355+
<entry><type>name</type></entry>
6356+
<entry></entry>
6357+
<entry>Name of the subscription</entry>
6358+
</row>
6359+
6360+
<row>
6361+
<entry><structfield>subowner</structfield></entry>
6362+
<entry><type>oid</type></entry>
6363+
<entry><literal><link linkend="catalog-pg-authid"><structname>pg_authid</structname></link>.oid</literal></entry>
6364+
<entry>Owner of the subscription</entry>
6365+
</row>
6366+
6367+
<row>
6368+
<entry><structfield>subenabled</structfield></entry>
6369+
<entry><type>bool</type></entry>
6370+
<entry></entry>
6371+
<entry>If true, the subscription is enabled and should be replicating.</entry>
6372+
</row>
6373+
6374+
<row>
6375+
<entry><structfield>subconninfo</structfield></entry>
6376+
<entry><type>text</type></entry>
6377+
<entry></entry>
6378+
<entry>Connection string to the upstream database</entry>
6379+
</row>
6380+
6381+
<row>
6382+
<entry><structfield>subslotname</structfield></entry>
6383+
<entry><type>name</type></entry>
6384+
<entry></entry>
6385+
<entry>Name of the replication slot in the upstream database. Also used
6386+
for local replication origin name.</entry>
6387+
</row>
6388+
6389+
<row>
6390+
<entry><structfield>subpublications</structfield></entry>
6391+
<entry><type>text[]</type></entry>
6392+
<entry></entry>
6393+
<entry>Array of subscribed publication names. These reference the
6394+
publications on the publisher server. For more on publications
6395+
see <xref linkend="logical-replication-publication">.
6396+
</entry>
6397+
</row>
6398+
</tbody>
6399+
</tgroup>
6400+
</table>
6401+
</sect1>
61536402

61546403
<sect1 id="catalog-pg-tablespace">
61556404
<title><structname>pg_tablespace</structname></title>
@@ -7589,6 +7838,11 @@
75897838
<entry>prepared transactions</entry>
75907839
</row>
75917840

7841+
<row>
7842+
<entry><link linkend="view-pg-publication-tables"><structname>pg_publication_tables</structname></link></entry>
7843+
<entry>publications and their associated tables</entry>
7844+
</row>
7845+
75927846
<row>
75937847
<entry><link linkend="view-pg-replication-origin-status"><structname>pg_replication_origin_status</structname></link></entry>
75947848
<entry>information about replication origins, including replication progress</entry>
@@ -8871,6 +9125,61 @@ SELECT * FROM pg_locks pl LEFT JOIN pg_prepared_xacts ppx
88719125

88729126
</sect1>
88739127

9128+
<sect1 id="view-pg-publication-tables">
9129+
<title><structname>pg_publication_tables</structname></title>
9130+
9131+
<indexterm zone="view-pg-publication-tables">
9132+
<primary>pg_publication_tables</primary>
9133+
</indexterm>
9134+
9135+
<para>
9136+
The view <structname>pg_publication_tables</structname> provides
9137+
information about the mapping between publications and the tables they
9138+
contain. Unlike the underlying
9139+
catalog <structname>pg_publication_rel</structname>, this view expands
9140+
publications defined as <literal>FOR ALL TABLES</literal>, so for such
9141+
publications there will be a row for each eligible table.
9142+
</para>
9143+
9144+
<table>
9145+
<title><structname>pg_publication_tables</structname> Columns</title>
9146+
9147+
<tgroup cols="4">
9148+
<thead>
9149+
<row>
9150+
<entry>Name</entry>
9151+
<entry>Type</entry>
9152+
<entry>References</entry>
9153+
<entry>Description</entry>
9154+
</row>
9155+
</thead>
9156+
9157+
<tbody>
9158+
<row>
9159+
<entry><structfield>pubname</structfield></entry>
9160+
<entry><type>name</type></entry>
9161+
<entry><literal><link linkend="catalog-pg-publication"><structname>pg_publication</structname></link>.pubname</literal></entry>
9162+
<entry>Name of publication</entry>
9163+
</row>
9164+
9165+
<row>
9166+
<entry><structfield>schemaname</structfield></entry>
9167+
<entry><type>name</type></entry>
9168+
<entry><literal><link linkend="catalog-pg-namespace"><structname>pg_namespace</structname></link>.nspname</literal></entry>
9169+
<entry>Name of schema containing table</entry>
9170+
</row>
9171+
9172+
<row>
9173+
<entry><structfield>tablename</structfield></entry>
9174+
<entry><type>name</type></entry>
9175+
<entry><literal><link linkend="catalog-pg-class"><structname>pg_class</structname></link>.relname</literal></entry>
9176+
<entry>Name of table</entry>
9177+
</row>
9178+
</tbody>
9179+
</tgroup>
9180+
</table>
9181+
</sect1>
9182+
88749183
<sect1 id="view-pg-replication-origin-status">
88759184
<title><structname>pg_replication_origin_status</structname></title>
88769185

doc/src/sgml/config.sgml

+41
Original file line numberDiff line numberDiff line change
@@ -3411,6 +3411,47 @@ ANY <replaceable class="parameter">num_sync</replaceable> ( <replaceable class="
34113411

34123412
</variablelist>
34133413
</sect2>
3414+
3415+
<sect2 id="runtime-config-replication-subscriber">
3416+
<title>Subscribers</title>
3417+
3418+
<para>
3419+
These settings control the behavior of a logical replication subscriber.
3420+
Their values on the publisher are irrelevant.
3421+
</para>
3422+
3423+
<para>
3424+
Note that <varname>wal_receiver_timeout</varname> and
3425+
<varname>wal_retrieve_retry_interval</varname> configuration parameters
3426+
affect the logical replication workers as well.
3427+
</para>
3428+
3429+
<variablelist>
3430+
3431+
<varlistentry id="guc-max-logical-replication-workers" xreflabel="max_logical_replication_workers">
3432+
<term><varname>max_logical_replication_workers</varname> (<type>int</type>)
3433+
<indexterm>
3434+
<primary><varname>max_logical_replication_workers</> configuration parameter</primary>
3435+
</indexterm>
3436+
</term>
3437+
<listitem>
3438+
<para>
3439+
Specifies maximum number of logical replication workers. This includes
3440+
both apply workers and table synchronization workers.
3441+
</para>
3442+
<para>
3443+
Logical replication workers are taken from the pool defined by
3444+
<varname>max_worker_processes</varname>.
3445+
</para>
3446+
<para>
3447+
The default value is 4.
3448+
</para>
3449+
</listitem>
3450+
</varlistentry>
3451+
3452+
</variablelist>
3453+
</sect2>
3454+
34143455
</sect1>
34153456

34163457
<sect1 id="runtime-config-query">

0 commit comments

Comments
 (0)