aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorSimon Riggs <simon@2ndQuadrant.com>2011-04-04 23:23:13 +0100
committerSimon Riggs <simon@2ndQuadrant.com>2011-04-04 23:23:13 +0100
commit88f32b7ca29982f286b61a9d0dd29be4b8a01c25 (patch)
tree98615ec86f009156f1766ee9a77b57e855f7c085 /src
parent479ee1b962ca2d479310af762c21d7c2056fdeca (diff)
downloadpostgresql-88f32b7ca29982f286b61a9d0dd29be4b8a01c25.tar.gz
postgresql-88f32b7ca29982f286b61a9d0dd29be4b8a01c25.zip
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.
Diffstat (limited to 'src')
-rw-r--r--src/backend/access/transam/xact.c2
-rw-r--r--src/backend/postmaster/autovacuum.c2
-rw-r--r--src/backend/utils/misc/guc.c2
-rw-r--r--src/include/access/xact.h9
-rw-r--r--src/include/replication/syncrep.h2
5 files changed, 10 insertions, 7 deletions
diff --git a/src/backend/access/transam/xact.c b/src/backend/access/transam/xact.c
index 503506f1f0d..55aee879101 100644
--- a/src/backend/access/transam/xact.c
+++ b/src/backend/access/transam/xact.c
@@ -1056,7 +1056,7 @@ RecordTransactionCommit(void)
* if all to-be-deleted tables are temporary though, since they are lost
* anyway if we crash.)
*/
- if ((wrote_xlog && synchronous_commit >= SYNCHRONOUS_COMMIT_LOCAL) ||
+ if ((wrote_xlog && synchronous_commit > SYNCHRONOUS_COMMIT_OFF) ||
forceSyncCommit || nrels > 0)
{
/*
diff --git a/src/backend/postmaster/autovacuum.c b/src/backend/postmaster/autovacuum.c
index 675bfced63c..619facc7526 100644
--- a/src/backend/postmaster/autovacuum.c
+++ b/src/backend/postmaster/autovacuum.c
@@ -1531,7 +1531,7 @@ AutoVacWorkerMain(int argc, char *argv[])
* if we are waiting for standbys to connect. This is important to
* ensure we aren't blocked from performing anti-wraparound tasks.
*/
- if (synchronous_commit == SYNCHRONOUS_COMMIT_ON)
+ if (synchronous_commit > SYNCHRONOUS_COMMIT_LOCAL_FLUSH)
SetConfigOption("synchronous_commit", "local", PGC_SUSET, PGC_S_OVERRIDE);
/*
diff --git a/src/backend/utils/misc/guc.c b/src/backend/utils/misc/guc.c
index 1f7a7d24f83..2151fde3618 100644
--- a/src/backend/utils/misc/guc.c
+++ b/src/backend/utils/misc/guc.c
@@ -355,7 +355,7 @@ static const struct config_enum_entry constraint_exclusion_options[] = {
* accept all the likely variants of "on" and "off".
*/
static const struct config_enum_entry synchronous_commit_options[] = {
- {"local", SYNCHRONOUS_COMMIT_LOCAL, false},
+ {"local", SYNCHRONOUS_COMMIT_LOCAL_FLUSH, false},
{"on", SYNCHRONOUS_COMMIT_ON, false},
{"off", SYNCHRONOUS_COMMIT_OFF, false},
{"true", SYNCHRONOUS_COMMIT_ON, true},
diff --git a/src/include/access/xact.h b/src/include/access/xact.h
index 44101453445..8b60e8f1635 100644
--- a/src/include/access/xact.h
+++ b/src/include/access/xact.h
@@ -54,11 +54,14 @@ extern bool XactDeferrable;
typedef enum
{
- SYNCHRONOUS_COMMIT_OFF, /* asynchronous commit */
- SYNCHRONOUS_COMMIT_LOCAL, /* wait for only local flush */
- SYNCHRONOUS_COMMIT_ON /* wait for local flush and sync rep */
+ SYNCHRONOUS_COMMIT_OFF, /* asynchronous commit */
+ SYNCHRONOUS_COMMIT_LOCAL_FLUSH, /* wait for local flush only */
+ SYNCHRONOUS_COMMIT_REMOTE_FLUSH /* wait for local and remote flush */
} SyncCommitLevel;
+/* Define the default setting for synchonous_commit */
+#define SYNCHRONOUS_COMMIT_ON SYNCHRONOUS_COMMIT_REMOTE_FLUSH
+
/* Synchronous commit level */
extern int synchronous_commit;
diff --git a/src/include/replication/syncrep.h b/src/include/replication/syncrep.h
index 696edccb120..9022b965855 100644
--- a/src/include/replication/syncrep.h
+++ b/src/include/replication/syncrep.h
@@ -20,7 +20,7 @@
#include "utils/guc.h"
#define SyncRepRequested() \
- (max_wal_senders > 0 && synchronous_commit == SYNCHRONOUS_COMMIT_ON)
+ (max_wal_senders > 0 && synchronous_commit > SYNCHRONOUS_COMMIT_LOCAL_FLUSH)
/* syncRepState */
#define SYNC_REP_NOT_WAITING 0