|
47 | 47 |
|
48 | 48 | <para> |
49 | 49 | Before you can use logical decoding, you must set |
50 | | - <xref linkend="guc-wal-level"/> to <literal>logical</literal> and |
| 50 | + <xref linkend="guc-wal-level"/> to <literal>replica</literal> or higher and |
51 | 51 | <xref linkend="guc-max-replication-slots"/> to at least 1. Then, you |
52 | 52 | should connect to the target database (in the example |
53 | 53 | below, <literal>postgres</literal>) as a superuser. |
@@ -257,6 +257,47 @@ postgres=# select * from pg_logical_slot_get_changes('regression_slot', NULL, NU |
257 | 257 | log</link>, which describe changes on a storage level, into an |
258 | 258 | application-specific form such as a stream of tuples or SQL statements. |
259 | 259 | </para> |
| 260 | + |
| 261 | + <para> |
| 262 | + Logical decoding becomes available in two conditions: |
| 263 | + </para> |
| 264 | + <itemizedlist> |
| 265 | + <listitem> |
| 266 | + <para> |
| 267 | + When <xref linkend="guc-wal-level"/> is set to <literal>logical</literal>. |
| 268 | + </para> |
| 269 | + </listitem> |
| 270 | + <listitem> |
| 271 | + <para> |
| 272 | + When <xref linkend="guc-wal-level"/> is set to <literal>replica</literal> |
| 273 | + and at least one valid logical replication slot exists on the system. |
| 274 | + </para> |
| 275 | + </listitem> |
| 276 | + </itemizedlist> |
| 277 | + <para> |
| 278 | + If either condition is met, the operational WAL level becomes equivalent |
| 279 | + to <literal>logical</literal>, which can be monitored through the |
| 280 | + <xref linkend="guc-effective-wal-level"/> parameter. |
| 281 | + </para> |
| 282 | + <para> |
| 283 | + When <varname>wal_level</varname> is set to <literal>replica</literal>, |
| 284 | + logical decoding is automatically activated upon creation of the first |
| 285 | + logical replication slot. This activation process involves several steps |
| 286 | + and requires synchronization among processes, ensuring system-wide |
| 287 | + consistency. Conversely, if <varname>wal_level</varname> set to |
| 288 | + <literal>replica</literal> and the last logical replication slot is dropped |
| 289 | + or invalidated, logical decoding is automatically disabled. Note that the |
| 290 | + deactivation of logical decoding might take some time as it is performed |
| 291 | + asynchronously by the checkpointer process. |
| 292 | + </para> |
| 293 | + |
| 294 | + <caution> |
| 295 | + <para> |
| 296 | + When <varname>wal_level</varname> is set to <literal>replica</literal>, |
| 297 | + dropping or invalidating the last logical slot disables logical decoding |
| 298 | + on the primary, resulting in slots on standbys being invalidated. |
| 299 | + </para> |
| 300 | + </caution> |
260 | 301 | </sect2> |
261 | 302 |
|
262 | 303 | <sect2 id="logicaldecoding-replication-slots"> |
@@ -328,8 +369,7 @@ postgres=# select * from pg_logical_slot_get_changes('regression_slot', NULL, NU |
328 | 369 | that could be needed by the logical decoding on the standby (as it does |
329 | 370 | not know about the <literal>catalog_xmin</literal> on the standby). |
330 | 371 | Existing logical slots on standby also get invalidated if |
331 | | - <varname>wal_level</varname> on the primary is reduced to less than |
332 | | - <literal>logical</literal>. |
| 372 | + logical decoding is disabled on the primary. |
333 | 373 | This is done as soon as the standby detects such a change in the WAL stream. |
334 | 374 | It means that, for walsenders that are lagging (if any), some WAL records up |
335 | 375 | to the <varname>wal_level</varname> parameter change on the primary won't be |
|
0 commit comments