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

Commited4a1c8

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 parent4e95733 commited4a1c8

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
@@ -2343,14 +2343,26 @@ include_dir 'conf.d'
23432343
</term>
23442344
<listitem>
23452345
<para>
2346-
Specifies whether transaction commit will wait for WAL records
2347-
to be written to disk before the command returns a <quote>success</>
2348-
indication to the client. Valid values are <literal>on</>,
2349-
<literal>remote_apply</>, <literal>remote_write</>, <literal>local</>,
2350-
and <literal>off</>. The default, and safe, setting
2351-
is <literal>on</>. When <literal>off</>, there can be a delay between
2352-
when success is reported to the client and when the transaction is
2353-
really guaranteed to be safe against a server crash. (The maximum
2346+
Specifies how much WAL processing must complete before
2347+
the database server returns a <quote>success</quote>
2348+
indication to the client. Valid values are
2349+
<literal>remote_apply</literal>, <literal>on</literal>
2350+
(the default), <literal>remote_write</literal>,
2351+
<literal>local</literal>, and <literal>off</literal>.
2352+
</para>
2353+
2354+
<para>
2355+
If <varname>synchronous_standby_names</varname> is empty,
2356+
the only meaningful settings are <literal>on</literal> and
2357+
<literal>off</literal>; <literal>remote_apply</literal>,
2358+
<literal>remote_write</literal> and <literal>local</literal>
2359+
all provide the same local synchronization level
2360+
as <literal>on</literal>. The local behavior of all
2361+
non-<literal>off</literal> modes is to wait for local flush of WAL
2362+
to disk. In <literal>off</literal> mode, there is no waiting,
2363+
so there can be a delay between when success is reported to the
2364+
client and when the transaction is later guaranteed to be safe
2365+
against a server crash. (The maximum
23542366
delay is three times <xref linkend="guc-wal-writer-delay">.) Unlike
23552367
<xref linkend="guc-fsync">, setting this parameter to <literal>off</>
23562368
does not create any risk of database inconsistency: an operating
@@ -2362,38 +2374,40 @@ include_dir 'conf.d'
23622374
exact certainty about the durability of a transaction. For more
23632375
discussion see <xref linkend="wal-async-commit">.
23642376
</para>
2377+
23652378
<para>
2366-
If <xref linkend="guc-synchronous-standby-names"> is non-empty, this
2367-
parameter also controls whether or not transaction commits will wait
2368-
for their WAL records to be replicated to the standby server(s).
2369-
When set to <literal>on</>, commits will wait until replies
2379+
If <xref linkend="guc-synchronous-standby-names"> is non-empty,
2380+
<varname>synchronous_commit</varname> also controls whether
2381+
transaction commits will wait for their WAL records to be
2382+
processed on the standby server(s).
2383+
</para>
2384+
2385+
<para>
2386+
When set to <literal>remote_apply</literal>, commits will wait
2387+
until replies from the current synchronous standby(s) indicate they
2388+
have received the commit record of the transaction and applied
2389+
it, so that it has become visible to queries on the standby(s),
2390+
and also written to durable storage on the standbys. This will
2391+
cause much larger commit delays than previous settings since
2392+
it waits for WAL replay. When set to <literal>on</literal>,
2393+
commits wait until replies
23702394
from the current synchronous standby(s) indicate they have received
2371-
the commit record of the transaction and flushed it todisk. This
2395+
the commit record of the transaction and flushed it todurable storage. This
23722396
ensures the transaction will not be lost unless both the primary and
23732397
all synchronous standbys suffer corruption of their database storage.
2374-
When set to <literal>remote_apply</>, commits will wait until replies
2375-
from the current synchronous standby(s) indicate they have received the
2376-
commit record of the transaction and applied it, so that it has become
2377-
visible to queries on the standby(s).
23782398
When set to <literal>remote_write</>, commits will wait until replies
23792399
from the current synchronous standby(s) indicate they have
2380-
received the commit record of the transaction and written it out to
2381-
their operating system. This setting is sufficient to
2382-
ensure data preservation even if a standby instance of
2383-
<productname>PostgreSQL</> were to crash, but not if the standby
2384-
suffers an operating-system-level crash, since the data has not
2400+
received the commit record of the transaction and written it to
2401+
their file systems. This setting ensures data preservation if a standby instance of
2402+
<productname>PostgreSQL</productname> crashes, but not if the standby
2403+
suffers an operating-system-level crash because the data has not
23852404
necessarily reached durable storage on the standby.
2386-
Finally, thesetting <literal>local</> causes commits to wait for
2387-
local flush to disk, but not for replication. This isnotusually
2405+
Thesetting <literal>local</literal> causes commits to wait for
2406+
local flush to disk, but not for replication. This is usually not
23882407
desirable when synchronous replication is in use, but is provided for
23892408
completeness.
23902409
</para>
2391-
<para>
2392-
If <varname>synchronous_standby_names</> is empty, the settings
2393-
<literal>on</>, <literal>remote_apply</>, <literal>remote_write</>
2394-
and <literal>local</> all provide the same synchronization level:
2395-
transaction commits only wait for local flush to disk.
2396-
</para>
2410+
23972411
<para>
23982412
This parameter can be changed at any time; the behavior for any
23992413
one transaction is determined by the setting in effect when it
@@ -2403,6 +2417,76 @@ include_dir 'conf.d'
24032417
asynchronously when the default is the opposite, issue <command>SET
24042418
LOCAL synchronous_commit TO OFF</> within the transaction.
24052419
</para>
2420+
2421+
<para>
2422+
<xref linkend="synchronous-commit-matrix"> summarizes the
2423+
capabilities of the <varname>synchronous_commit</varname> settings.
2424+
</para>
2425+
2426+
<table id="synchronous-commit-matrix">
2427+
<title>synchronous_commit Modes</title>
2428+
<tgroup cols="5">
2429+
<colspec colname="col1" colwidth="1.1*">
2430+
<colspec colname="col2" colwidth="1*">
2431+
<colspec colname="col3" colwidth="1*">
2432+
<colspec colname="col4" colwidth="1*">
2433+
<colspec colname="col5" colwidth="1*">
2434+
<thead>
2435+
<row>
2436+
<entry>synchronous_commit setting</entry>
2437+
<entry>local durable commit</entry>
2438+
<entry>standby durable commit after PG crash</entry>
2439+
<entry>standby durable commit after OS crash</entry>
2440+
<entry>standby query consistency</entry>
2441+
</row>
2442+
</thead>
2443+
2444+
<tbody>
2445+
2446+
<row>
2447+
<entry>remote_apply</entry>
2448+
<entry align="center">&bull;</entry>
2449+
<entry align="center">&bull;</entry>
2450+
<entry align="center">&bull;</entry>
2451+
<entry align="center">&bull;</entry>
2452+
</row>
2453+
2454+
<row>
2455+
<entry>on</entry>
2456+
<entry align="center">&bull;</entry>
2457+
<entry align="center">&bull;</entry>
2458+
<entry align="center">&bull;</entry>
2459+
<entry align="center"></entry>
2460+
</row>
2461+
2462+
<row>
2463+
<entry>remote_write</entry>
2464+
<entry align="center">&bull;</entry>
2465+
<entry align="center">&bull;</entry>
2466+
<entry align="center"></entry>
2467+
<entry align="center"></entry>
2468+
</row>
2469+
2470+
<row>
2471+
<entry>local</entry>
2472+
<entry align="center">&bull;</entry>
2473+
<entry align="center"></entry>
2474+
<entry align="center"></entry>
2475+
<entry align="center"></entry>
2476+
</row>
2477+
2478+
<row>
2479+
<entry>off</entry>
2480+
<entry align="center"></entry>
2481+
<entry align="center"></entry>
2482+
<entry align="center"></entry>
2483+
<entry align="center"></entry>
2484+
</row>
2485+
2486+
</tbody>
2487+
</tgroup>
2488+
</table>
2489+
24062490
</listitem>
24072491
</varlistentry>
24082492

‎src/include/access/xact.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,8 @@ typedef enum
6161
SYNCHRONOUS_COMMIT_REMOTE_WRITE,/* wait for local flush and remote
6262
* write */
6363
SYNCHRONOUS_COMMIT_REMOTE_FLUSH,/* wait for local and remote flush */
64-
SYNCHRONOUS_COMMIT_REMOTE_APPLY/* wait for local flush and remote apply */
64+
SYNCHRONOUS_COMMIT_REMOTE_APPLY/* wait for local and remote flush
65+
and remote apply */
6566
}SyncCommitLevel;
6667

6768
/* Define the default setting for synchronous_commit */

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp