|
24 | 24 | </para>
|
25 | 25 |
|
26 | 26 | <para>
|
27 |
| - Logical replication sends the changes on the publisher to the subscriber as |
| 27 | + Logical replication sends changes on the publisher to the subscriber as |
28 | 28 | they occur in real-time. The subscriber applies the data in the same order
|
29 | 29 | as the publisher so that transactional consistency is guaranteed for
|
30 | 30 | publications within a single subscription. This method of data replication
|
|
44 | 44 |
|
45 | 45 | <listitem>
|
46 | 46 | <para>
|
47 |
| - Firing triggers for individual changes as they are incoming to |
| 47 | + Firing triggers for individual changes as they arrive on the |
48 | 48 | subscriber.
|
49 | 49 | </para>
|
50 | 50 | </listitem>
|
|
81 | 81 | instance and can be used as a publisher for other databases by defining its
|
82 | 82 | own publications. When the subscriber is treated as read-only by
|
83 | 83 | application, there will be no conflicts from a single subscription. On the
|
84 |
| - other hand, if there are other writes done either by application or other |
85 |
| - subscribers to the same set of tables conflicts can arise. |
| 84 | + other hand, if there are other writes done either by an application or by other |
| 85 | + subscribers to the same set of tables, conflicts can arise. |
86 | 86 | </para>
|
87 | 87 |
|
88 | 88 | <sect1 id="logical-replication-publication">
|
89 | 89 | <title>Publication</title>
|
90 | 90 |
|
91 | 91 | <para>
|
92 |
| - A <firstterm>publication</firstterm> object can be defined on any physical |
| 92 | + A <firstterm>publication</firstterm> can be defined on any physical |
93 | 93 | replication master. The node where a publication is defined is referred to
|
94 | 94 | as <firstterm>publisher</firstterm>. A publication is a set of changes
|
95 |
| - generated from a group of tables, and might also be described as a change |
96 |
| - set or replication set. Each publication exists in only one database. |
| 95 | + generated from a table or a group of tables, and might also be described as |
| 96 | + a change set or replication set. Each publication exists in only one database. |
97 | 97 | </para>
|
98 | 98 |
|
99 | 99 | <para>
|
|
105 | 105 | </para>
|
106 | 106 |
|
107 | 107 | <para>
|
108 |
| - Publications can choose to limit the changes they produce to show |
| 108 | + Publications can choose to limit the changes they produce to |
109 | 109 | any combination of <command>INSERT</command>, <command>UPDATE</command>, and
|
110 |
| - <command>DELETE</command> in a similar way to the way triggers are fired by |
| 110 | + <command>DELETE</command>, similar to how triggers are fired by |
111 | 111 | particular event types. If a table without a <literal>REPLICA
|
112 | 112 | IDENTITY</literal> is added to a publication that
|
113 | 113 | replicates <command>UPDATE</command> or <command>DELETE</command>
|
|
121 | 121 |
|
122 | 122 | <para>
|
123 | 123 | A publication is created using the <xref linkend="sql-createpublication">
|
124 |
| - command and may be later altered or dropped using corresponding commands. |
| 124 | + command and may later be altered or dropped using corresponding commands. |
125 | 125 | </para>
|
126 | 126 |
|
127 | 127 | <para>
|
|
139 | 139 | <para>
|
140 | 140 | A <firstterm>subscription</firstterm> is the downstream side of logical
|
141 | 141 | replication. The node where a subscription is defined is referred to as
|
142 |
| - the <firstterm>subscriber</firstterm>. Subscription defines the connection |
| 142 | + the <firstterm>subscriber</firstterm>. A subscription defines the connection |
143 | 143 | to another database and set of publications (one or more) to which it wants
|
144 |
| - to be subscribed. |
| 144 | + to subscribe. |
145 | 145 | </para>
|
146 | 146 |
|
147 | 147 | <para>
|
|
153 | 153 | <para>
|
154 | 154 | A subscriber node may have multiple subscriptions if desired. It is
|
155 | 155 | possible to define multiple subscriptions between a single
|
156 |
| - publisher-subscriber pair, in which case extra care must be taken to ensure |
| 156 | + publisher-subscriber pair, in which case care must be taken to ensure |
157 | 157 | that the subscribed publication objects don't overlap.
|
158 | 158 | </para>
|
159 | 159 |
|
|
163 | 163 | </para>
|
164 | 164 |
|
165 | 165 | <para>
|
166 |
| - Subscriptions are not dumped by <command>pg_dump</command> by default but |
167 |
| - can be requested using the command-line |
168 |
| - option <option>--subscriptions</option>. |
| 166 | + Subscriptions are not dumped by <command>pg_dump</command> by default, but |
| 167 | + this can be requested using the command-line |
| 168 | + option <option>--include-subscriptions</option>. |
169 | 169 | </para>
|
170 | 170 |
|
171 | 171 | <para>
|
|
182 | 182 | </para>
|
183 | 183 |
|
184 | 184 | <para>
|
185 |
| - The schema definitions are not replicated and the published tables must |
186 |
| - exist on the subsriber for replication to work. Only regular tables may be |
| 185 | + The schema definitions are not replicated, and the published tables must |
| 186 | + exist on the subscriber. Only regular tables may be |
187 | 187 | the target of replication. For example, you can't replicate to a view.
|
188 | 188 | </para>
|
189 | 189 |
|
|
203 | 203 | <title>Conflicts</title>
|
204 | 204 |
|
205 | 205 | <para>
|
206 |
| - The logical replication behaves similarly to normal DML operations in that |
| 206 | + Logical replication behaves similarly to normal DML operations in that |
207 | 207 | the data will be updated even if it was changed locally on the subscriber
|
208 |
| - node. If the incoming data violates any constraints the replication will |
| 208 | + node. If incoming data violates any constraints the replication will |
209 | 209 | stop. This is referred to as a <firstterm>conflict</firstterm>. When
|
210 | 210 | replicating <command>UPDATE</command> or <command>DELETE</command>
|
211 | 211 | operations, missing data will not produce a conflict and such operations
|
|
224 | 224 | transaction that conflicts with the existing data. The transaction can be
|
225 | 225 | skipped by calling the <link linkend="pg-replication-origin-advance">
|
226 | 226 | <function>pg_replication_origin_advance()</function></link> function with
|
227 |
| - a <parameter>node_name</parameter> corresponding to the subscription name. |
228 |
| - The current position of origins can be seen in the |
| 227 | + a <parameter>node_name</parameter> corresponding to the subscription name, |
| 228 | + and a position. The current position of origins can be seen in the |
229 | 229 | <link linkend="view-pg-replication-origin-status">
|
230 | 230 | <structname>pg_replication_origin_status</structname></link> system view.
|
231 | 231 | </para>
|
|
246 | 246 | <para>
|
247 | 247 | Logical replication is built with an architecture similar to physical
|
248 | 248 | streaming replication (see <xref linkend="streaming-replication">). It is
|
249 |
| - implemented by <quote>walsender</quote> and the <quote>apply</quote> |
250 |
| - processes. The walsender starts logical decoding (described |
| 249 | + implemented by <quote>walsender</quote> and <quote>apply</quote> |
| 250 | + processes. The walsender process starts logical decoding (described |
251 | 251 | in <xref linkend="logicaldecoding">) of the WAL and loads the standard
|
252 | 252 | logical decoding plugin (pgoutput). The plugin transforms the changes read
|
253 | 253 | from WAL to the logical replication protocol
|
254 | 254 | (see <xref linkend="protocol-logical-replication">) and filters the data
|
255 | 255 | according to the publication specification. The data is then continuously
|
256 | 256 | transferred using the streaming replication protocol to the apply worker,
|
257 | 257 | which maps the data to local tables and applies the individual changes as
|
258 |
| - they are received in exact transactional order. |
| 258 | + they are received, in correct transactional order. |
259 | 259 | </para>
|
260 | 260 |
|
261 | 261 | <para>
|
|
270 | 270 | <title>Monitoring</title>
|
271 | 271 |
|
272 | 272 | <para>
|
273 |
| - Because logical replication is based on similar architecture as |
274 |
| - <link linkend="streaming-replication">physical streaming replication</link> |
275 |
| - the monitoring on a publication node is very similar to monitoring of |
| 273 | + Because logical replication is based on a similar architecture as |
| 274 | + <link linkend="streaming-replication">physical streaming replication</link>, |
| 275 | + the monitoring on a publication node is similar to monitoring of a |
276 | 276 | physical replication master
|
277 | 277 | (see <xref linkend="streaming-replication-monitoring">).
|
278 | 278 | </para>
|
|
295 | 295 | <title>Security</title>
|
296 | 296 |
|
297 | 297 | <para>
|
298 |
| - Logical replication connections occur in the same way as physical streaming |
299 |
| - replication. It requires access to be specifically given using |
| 298 | + Logical replication connections occur in the same way as with physical streaming |
| 299 | + replication. It requires access to be explicitly given using |
300 | 300 | <filename>pg_hba.conf</filename>. The role used for the replication
|
301 | 301 | connection must have the <literal>REPLICATION</literal> attribute. This
|
302 | 302 | gives a role access to both logical and physical replication.
|
|
333 | 333 | <para>
|
334 | 334 | On the publisher side, <varname>wal_level</varname> must be set to
|
335 | 335 | <literal>logical</literal>, and <varname>max_replication_slots</varname>
|
336 |
| - has to be set to at least the number of subscriptions expected to connect. |
| 336 | + must be set to at least the number of subscriptions expected to connect. |
337 | 337 | And <varname>max_wal_senders</varname> should be set to at least the same
|
338 | 338 | as <varname>max_replication_slots</varname> plus the number of physical replicas
|
339 | 339 | that are connected at the same time.
|
|
343 | 343 | The subscriber also requires the <varname>max_replication_slots</varname>
|
344 | 344 | to be set. In this case it should be set to at least the number of
|
345 | 345 | subscriptions that will be added to the subscriber.
|
346 |
| - <varname>max_logical_replication_workers</varname> has to be set to at |
| 346 | + <varname>max_logical_replication_workers</varname> must be set to at |
347 | 347 | least the number of subscriptions. Additionally the
|
348 | 348 | <varname>max_worker_processes</varname> may need to be adjusted to
|
349 | 349 | accommodate for replication workers, at least
|
|
0 commit comments