Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitf915453

Browse files
committed
doc: improve description of synchronous_commit modes
Previously it wasn't clear exactly what each of the synchronous_commitmodes accomplished. This clarifies that, and adds a table describing it.Only backpatched through 9.6 since 9.5 doesn't have all the options.Reported-by: kghost0@gmail.comDiscussion:https://postgr.es/m/159741195522.14321.13812604195366728976@wrigleys.postgresql.orgBackpatch-through: 9.6
1 parent8b53dba commitf915453

File tree

2 files changed

+116
-31
lines changed

2 files changed

+116
-31
lines changed

‎doc/src/sgml/config.sgml

Lines changed: 114 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -2571,14 +2571,26 @@ include_dir 'conf.d'
25712571
</term>
25722572
<listitem>
25732573
<para>
2574-
Specifies whether transaction commit will wait for WAL records
2575-
to be written to disk before the command returns a <quote>success</quote>
2576-
indication to the client. Valid values are <literal>on</literal>,
2577-
<literal>remote_apply</literal>, <literal>remote_write</literal>, <literal>local</literal>,
2578-
and <literal>off</literal>. The default, and safe, setting
2579-
is <literal>on</literal>. When <literal>off</literal>, there can be a delay between
2580-
when success is reported to the client and when the transaction is
2581-
really guaranteed to be safe against a server crash. (The maximum
2574+
Specifies how much WAL processing must complete before
2575+
the database server returns a <quote>success</quote>
2576+
indication to the client. Valid values are
2577+
<literal>remote_apply</literal>, <literal>on</literal>
2578+
(the default), <literal>remote_write</literal>,
2579+
<literal>local</literal>, and <literal>off</literal>.
2580+
</para>
2581+
2582+
<para>
2583+
If <varname>synchronous_standby_names</varname> is empty,
2584+
the only meaningful settings are <literal>on</literal> and
2585+
<literal>off</literal>; <literal>remote_apply</literal>,
2586+
<literal>remote_write</literal> and <literal>local</literal>
2587+
all provide the same local synchronization level
2588+
as <literal>on</literal>. The local behavior of all
2589+
non-<literal>off</literal> modes is to wait for local flush of WAL
2590+
to disk. In <literal>off</literal> mode, there is no waiting,
2591+
so there can be a delay between when success is reported to the
2592+
client and when the transaction is later guaranteed to be safe
2593+
against a server crash. (The maximum
25822594
delay is three times <xref linkend="guc-wal-writer-delay"/>.) Unlike
25832595
<xref linkend="guc-fsync"/>, setting this parameter to <literal>off</literal>
25842596
does not create any risk of database inconsistency: an operating
@@ -2590,38 +2602,40 @@ include_dir 'conf.d'
25902602
exact certainty about the durability of a transaction. For more
25912603
discussion see <xref linkend="wal-async-commit"/>.
25922604
</para>
2605+
25932606
<para>
2594-
If <xref linkend="guc-synchronous-standby-names"/> is non-empty, this
2595-
parameter also controls whether or not transaction commits will wait
2596-
for their WAL records to be replicated to the standby server(s).
2597-
When set to <literal>on</literal>, commits will wait until replies
2607+
If <xref linkend="guc-synchronous-standby-names"/> is non-empty,
2608+
<varname>synchronous_commit</varname> also controls whether
2609+
transaction commits will wait for their WAL records to be
2610+
processed on the standby server(s).
2611+
</para>
2612+
2613+
<para>
2614+
When set to <literal>remote_apply</literal>, commits will wait
2615+
until replies from the current synchronous standby(s) indicate they
2616+
have received the commit record of the transaction and applied
2617+
it, so that it has become visible to queries on the standby(s),
2618+
and also written to durable storage on the standbys. This will
2619+
cause much larger commit delays than previous settings since
2620+
it waits for WAL replay. When set to <literal>on</literal>,
2621+
commits wait until replies
25982622
from the current synchronous standby(s) indicate they have received
2599-
the commit record of the transaction and flushed it todisk. This
2623+
the commit record of the transaction and flushed it todurable storage. This
26002624
ensures the transaction will not be lost unless both the primary and
26012625
all synchronous standbys suffer corruption of their database storage.
2602-
When set to <literal>remote_apply</literal>, commits will wait until replies
2603-
from the current synchronous standby(s) indicate they have received the
2604-
commit record of the transaction and applied it, so that it has become
2605-
visible to queries on the standby(s).
26062626
When set to <literal>remote_write</literal>, commits will wait until replies
26072627
from the current synchronous standby(s) indicate they have
2608-
received the commit record of the transaction and written it out to
2609-
their operating system. This setting is sufficient to
2610-
ensure data preservation even if a standby instance of
2611-
<productname>PostgreSQL</productname> were to crash, but not if the standby
2612-
suffers an operating-system-level crash, since the data has not
2628+
received the commit record of the transaction and written it to
2629+
their file systems. This setting ensures data preservation if a standby instance of
2630+
<productname>PostgreSQL</productname> crashes, but not if the standby
2631+
suffers an operating-system-level crash because the data has not
26132632
necessarily reached durable storage on the standby.
2614-
Finally, the setting <literal>local</literal> causes commits to wait for
2615-
local flush to disk, but not for replication. This isnotusually
2633+
The setting <literal>local</literal> causes commits to wait for
2634+
local flush to disk, but not for replication. This is usually not
26162635
desirable when synchronous replication is in use, but is provided for
26172636
completeness.
26182637
</para>
2619-
<para>
2620-
If <varname>synchronous_standby_names</varname> is empty, the settings
2621-
<literal>on</literal>, <literal>remote_apply</literal>, <literal>remote_write</literal>
2622-
and <literal>local</literal> all provide the same synchronization level:
2623-
transaction commits only wait for local flush to disk.
2624-
</para>
2638+
26252639
<para>
26262640
This parameter can be changed at any time; the behavior for any
26272641
one transaction is determined by the setting in effect when it
@@ -2631,6 +2645,76 @@ include_dir 'conf.d'
26312645
asynchronously when the default is the opposite, issue <command>SET
26322646
LOCAL synchronous_commit TO OFF</command> within the transaction.
26332647
</para>
2648+
2649+
<para>
2650+
<xref linkend="synchronous-commit-matrix"/> summarizes the
2651+
capabilities of the <varname>synchronous_commit</varname> settings.
2652+
</para>
2653+
2654+
<table id="synchronous-commit-matrix">
2655+
<title>synchronous_commit Modes</title>
2656+
<tgroup cols="5">
2657+
<colspec colname="col1" colwidth="1.1*"/>
2658+
<colspec colname="col2" colwidth="1*"/>
2659+
<colspec colname="col3" colwidth="1*"/>
2660+
<colspec colname="col4" colwidth="1*"/>
2661+
<colspec colname="col5" colwidth="1*"/>
2662+
<thead>
2663+
<row>
2664+
<entry>synchronous_commit setting</entry>
2665+
<entry>local durable commit</entry>
2666+
<entry>standby durable commit after PG crash</entry>
2667+
<entry>standby durable commit after OS crash</entry>
2668+
<entry>standby query consistency</entry>
2669+
</row>
2670+
</thead>
2671+
2672+
<tbody>
2673+
2674+
<row>
2675+
<entry>remote_apply</entry>
2676+
<entry align="center">&bull;</entry>
2677+
<entry align="center">&bull;</entry>
2678+
<entry align="center">&bull;</entry>
2679+
<entry align="center">&bull;</entry>
2680+
</row>
2681+
2682+
<row>
2683+
<entry>on</entry>
2684+
<entry align="center">&bull;</entry>
2685+
<entry align="center">&bull;</entry>
2686+
<entry align="center">&bull;</entry>
2687+
<entry align="center"></entry>
2688+
</row>
2689+
2690+
<row>
2691+
<entry>remote_write</entry>
2692+
<entry align="center">&bull;</entry>
2693+
<entry align="center">&bull;</entry>
2694+
<entry align="center"></entry>
2695+
<entry align="center"></entry>
2696+
</row>
2697+
2698+
<row>
2699+
<entry>local</entry>
2700+
<entry align="center">&bull;</entry>
2701+
<entry align="center"></entry>
2702+
<entry align="center"></entry>
2703+
<entry align="center"></entry>
2704+
</row>
2705+
2706+
<row>
2707+
<entry>off</entry>
2708+
<entry align="center"></entry>
2709+
<entry align="center"></entry>
2710+
<entry align="center"></entry>
2711+
<entry align="center"></entry>
2712+
</row>
2713+
2714+
</tbody>
2715+
</tgroup>
2716+
</table>
2717+
26342718
</listitem>
26352719
</varlistentry>
26362720

‎src/include/access/xact.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,8 @@ typedef enum
7272
SYNCHRONOUS_COMMIT_REMOTE_WRITE,/* wait for local flush and remote
7373
* write */
7474
SYNCHRONOUS_COMMIT_REMOTE_FLUSH,/* wait for local and remote flush */
75-
SYNCHRONOUS_COMMIT_REMOTE_APPLY/* wait for local flush and remote apply */
75+
SYNCHRONOUS_COMMIT_REMOTE_APPLY/* wait for local and remote flush
76+
and remote apply */
7677
}SyncCommitLevel;
7778

7879
/* Define the default setting for synchronous_commit */

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp