Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 88f32b7

Browse files
Avoid assuming there will be only 3 states for synchronous_commit.
Also avoid hardcoding the current default state by giving it the name "on" and replace with a meaningful name that reflects its behaviour. Coding only, no change in behaviour.
1 parent 479ee1b commit 88f32b7

File tree

5 files changed

+10
-7
lines changed

5 files changed

+10
-7
lines changed

src/backend/access/transam/xact.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -1056,7 +1056,7 @@ RecordTransactionCommit(void)
10561056
* if all to-be-deleted tables are temporary though, since they are lost
10571057
* anyway if we crash.)
10581058
*/
1059-
if ((wrote_xlog && synchronous_commit >= SYNCHRONOUS_COMMIT_LOCAL) ||
1059+
if ((wrote_xlog && synchronous_commit > SYNCHRONOUS_COMMIT_OFF) ||
10601060
forceSyncCommit || nrels > 0)
10611061
{
10621062
/*

src/backend/postmaster/autovacuum.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -1531,7 +1531,7 @@ AutoVacWorkerMain(int argc, char *argv[])
15311531
* if we are waiting for standbys to connect. This is important to
15321532
* ensure we aren't blocked from performing anti-wraparound tasks.
15331533
*/
1534-
if (synchronous_commit == SYNCHRONOUS_COMMIT_ON)
1534+
if (synchronous_commit > SYNCHRONOUS_COMMIT_LOCAL_FLUSH)
15351535
SetConfigOption("synchronous_commit", "local", PGC_SUSET, PGC_S_OVERRIDE);
15361536

15371537
/*

src/backend/utils/misc/guc.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -355,7 +355,7 @@ static const struct config_enum_entry constraint_exclusion_options[] = {
355355
* accept all the likely variants of "on" and "off".
356356
*/
357357
static const struct config_enum_entry synchronous_commit_options[] = {
358-
{"local", SYNCHRONOUS_COMMIT_LOCAL, false},
358+
{"local", SYNCHRONOUS_COMMIT_LOCAL_FLUSH, false},
359359
{"on", SYNCHRONOUS_COMMIT_ON, false},
360360
{"off", SYNCHRONOUS_COMMIT_OFF, false},
361361
{"true", SYNCHRONOUS_COMMIT_ON, true},

src/include/access/xact.h

+6-3
Original file line numberDiff line numberDiff line change
@@ -54,11 +54,14 @@ extern bool XactDeferrable;
5454

5555
typedef enum
5656
{
57-
SYNCHRONOUS_COMMIT_OFF, /* asynchronous commit */
58-
SYNCHRONOUS_COMMIT_LOCAL, /* wait for only local flush */
59-
SYNCHRONOUS_COMMIT_ON /* wait for local flush and sync rep */
57+
SYNCHRONOUS_COMMIT_OFF, /* asynchronous commit */
58+
SYNCHRONOUS_COMMIT_LOCAL_FLUSH, /* wait for local flush only */
59+
SYNCHRONOUS_COMMIT_REMOTE_FLUSH /* wait for local and remote flush */
6060
} SyncCommitLevel;
6161

62+
/* Define the default setting for synchonous_commit */
63+
#define SYNCHRONOUS_COMMIT_ON SYNCHRONOUS_COMMIT_REMOTE_FLUSH
64+
6265
/* Synchronous commit level */
6366
extern int synchronous_commit;
6467

src/include/replication/syncrep.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
#include "utils/guc.h"
2121

2222
#define SyncRepRequested() \
23-
(max_wal_senders > 0 && synchronous_commit == SYNCHRONOUS_COMMIT_ON)
23+
(max_wal_senders > 0 && synchronous_commit > SYNCHRONOUS_COMMIT_LOCAL_FLUSH)
2424

2525
/* syncRepState */
2626
#define SYNC_REP_NOT_WAITING 0

0 commit comments

Comments
 (0)