@@ -2650,14 +2650,26 @@ include_dir 'conf.d'
2650
2650
</term>
2651
2651
<listitem>
2652
2652
<para>
2653
- Specifies whether transaction commit will wait for WAL records
2654
- to be written to disk before the command returns a <quote>success</quote>
2655
- indication to the client. Valid values are <literal>on</literal>,
2656
- <literal>remote_apply</literal>, <literal>remote_write</literal>, <literal>local</literal>,
2657
- and <literal>off</literal>. The default, and safe, setting
2658
- is <literal>on</literal>. When <literal>off</literal>, there can be a delay between
2659
- when success is reported to the client and when the transaction is
2660
- really guaranteed to be safe against a server crash. (The maximum
2653
+ Specifies how much WAL processing must complete before
2654
+ the database server returns a <quote>success</quote>
2655
+ indication to the client. Valid values are
2656
+ <literal>remote_apply</literal>, <literal>on</literal>
2657
+ (the default), <literal>remote_write</literal>,
2658
+ <literal>local</literal>, and <literal>off</literal>.
2659
+ </para>
2660
+
2661
+ <para>
2662
+ If <varname>synchronous_standby_names</varname> is empty,
2663
+ the only meaningful settings are <literal>on</literal> and
2664
+ <literal>off</literal>; <literal>remote_apply</literal>,
2665
+ <literal>remote_write</literal> and <literal>local</literal>
2666
+ all provide the same local synchronization level
2667
+ as <literal>on</literal>. The local behavior of all
2668
+ non-<literal>off</literal> modes is to wait for local flush of WAL
2669
+ to disk. In <literal>off</literal> mode, there is no waiting,
2670
+ so there can be a delay between when success is reported to the
2671
+ client and when the transaction is later guaranteed to be safe
2672
+ against a server crash. (The maximum
2661
2673
delay is three times <xref linkend="guc-wal-writer-delay"/>.) Unlike
2662
2674
<xref linkend="guc-fsync"/>, setting this parameter to <literal>off</literal>
2663
2675
does not create any risk of database inconsistency: an operating
@@ -2669,38 +2681,40 @@ include_dir 'conf.d'
2669
2681
exact certainty about the durability of a transaction. For more
2670
2682
discussion see <xref linkend="wal-async-commit"/>.
2671
2683
</para>
2684
+
2672
2685
<para>
2673
- If <xref linkend="guc-synchronous-standby-names"/> is non-empty, this
2674
- parameter also controls whether or not transaction commits will wait
2675
- for their WAL records to be replicated to the standby server(s).
2676
- When set to <literal>on</literal>, commits will wait until replies
2686
+ If <xref linkend="guc-synchronous-standby-names"/> is non-empty,
2687
+ <varname>synchronous_commit</varname> also controls whether
2688
+ transaction commits will wait for their WAL records to be
2689
+ processed on the standby server(s).
2690
+ </para>
2691
+
2692
+ <para>
2693
+ When set to <literal>remote_apply</literal>, commits will wait
2694
+ until replies from the current synchronous standby(s) indicate they
2695
+ have received the commit record of the transaction and applied
2696
+ it, so that it has become visible to queries on the standby(s),
2697
+ and also written to durable storage on the standbys. This will
2698
+ cause much larger commit delays than previous settings since
2699
+ it waits for WAL replay. When set to <literal>on</literal>,
2700
+ commits wait until replies
2677
2701
from the current synchronous standby(s) indicate they have received
2678
- the commit record of the transaction and flushed it to disk . This
2702
+ the commit record of the transaction and flushed it to durable storage . This
2679
2703
ensures the transaction will not be lost unless both the primary and
2680
2704
all synchronous standbys suffer corruption of their database storage.
2681
- When set to <literal>remote_apply</literal>, commits will wait until replies
2682
- from the current synchronous standby(s) indicate they have received the
2683
- commit record of the transaction and applied it, so that it has become
2684
- visible to queries on the standby(s).
2685
2705
When set to <literal>remote_write</literal>, commits will wait until replies
2686
2706
from the current synchronous standby(s) indicate they have
2687
- received the commit record of the transaction and written it out to
2688
- their operating system. This setting is sufficient to
2689
- ensure data preservation even if a standby instance of
2690
- <productname>PostgreSQL</productname> were to crash, but not if the standby
2691
- suffers an operating-system-level crash, since the data has not
2707
+ received the commit record of the transaction and written it to
2708
+ their file systems. This setting ensures data preservation if a standby instance of
2709
+ <productname>PostgreSQL</productname> crashes, but not if the standby
2710
+ suffers an operating-system-level crash because the data has not
2692
2711
necessarily reached durable storage on the standby.
2693
- Finally, the setting <literal>local</literal> causes commits to wait for
2694
- local flush to disk, but not for replication. This is not usually
2712
+ The setting <literal>local</literal> causes commits to wait for
2713
+ local flush to disk, but not for replication. This is usually not
2695
2714
desirable when synchronous replication is in use, but is provided for
2696
2715
completeness.
2697
2716
</para>
2698
- <para>
2699
- If <varname>synchronous_standby_names</varname> is empty, the settings
2700
- <literal>on</literal>, <literal>remote_apply</literal>, <literal>remote_write</literal>
2701
- and <literal>local</literal> all provide the same synchronization level:
2702
- transaction commits only wait for local flush to disk.
2703
- </para>
2717
+
2704
2718
<para>
2705
2719
This parameter can be changed at any time; the behavior for any
2706
2720
one transaction is determined by the setting in effect when it
@@ -2710,6 +2724,76 @@ include_dir 'conf.d'
2710
2724
asynchronously when the default is the opposite, issue <command>SET
2711
2725
LOCAL synchronous_commit TO OFF</command> within the transaction.
2712
2726
</para>
2727
+
2728
+ <para>
2729
+ <xref linkend="synchronous-commit-matrix"/> summarizes the
2730
+ capabilities of the <varname>synchronous_commit</varname> settings.
2731
+ </para>
2732
+
2733
+ <table id="synchronous-commit-matrix">
2734
+ <title>synchronous_commit Modes</title>
2735
+ <tgroup cols="5">
2736
+ <colspec colname="col1" colwidth="1.1*"/>
2737
+ <colspec colname="col2" colwidth="1*"/>
2738
+ <colspec colname="col3" colwidth="1*"/>
2739
+ <colspec colname="col4" colwidth="1*"/>
2740
+ <colspec colname="col5" colwidth="1*"/>
2741
+ <thead>
2742
+ <row>
2743
+ <entry>synchronous_commit setting</entry>
2744
+ <entry>local durable commit</entry>
2745
+ <entry>standby durable commit after PG crash</entry>
2746
+ <entry>standby durable commit after OS crash</entry>
2747
+ <entry>standby query consistency</entry>
2748
+ </row>
2749
+ </thead>
2750
+
2751
+ <tbody>
2752
+
2753
+ <row>
2754
+ <entry>remote_apply</entry>
2755
+ <entry align="center">•</entry>
2756
+ <entry align="center">•</entry>
2757
+ <entry align="center">•</entry>
2758
+ <entry align="center">•</entry>
2759
+ </row>
2760
+
2761
+ <row>
2762
+ <entry>on</entry>
2763
+ <entry align="center">•</entry>
2764
+ <entry align="center">•</entry>
2765
+ <entry align="center">•</entry>
2766
+ <entry align="center"></entry>
2767
+ </row>
2768
+
2769
+ <row>
2770
+ <entry>remote_write</entry>
2771
+ <entry align="center">•</entry>
2772
+ <entry align="center">•</entry>
2773
+ <entry align="center"></entry>
2774
+ <entry align="center"></entry>
2775
+ </row>
2776
+
2777
+ <row>
2778
+ <entry>local</entry>
2779
+ <entry align="center">•</entry>
2780
+ <entry align="center"></entry>
2781
+ <entry align="center"></entry>
2782
+ <entry align="center"></entry>
2783
+ </row>
2784
+
2785
+ <row>
2786
+ <entry>off</entry>
2787
+ <entry align="center"></entry>
2788
+ <entry align="center"></entry>
2789
+ <entry align="center"></entry>
2790
+ <entry align="center"></entry>
2791
+ </row>
2792
+
2793
+ </tbody>
2794
+ </tgroup>
2795
+ </table>
2796
+
2713
2797
</listitem>
2714
2798
</varlistentry>
2715
2799
0 commit comments