]> granicus.if.org Git - postgresql/commitdiff
Avoid assuming there will be only 3 states for synchronous_commit.
authorSimon Riggs <simon@2ndQuadrant.com>
Mon, 4 Apr 2011 22:23:13 +0000 (23:23 +0100)
committerSimon Riggs <simon@2ndQuadrant.com>
Mon, 4 Apr 2011 22:23:13 +0000 (23:23 +0100)
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.

src/backend/access/transam/xact.c
src/backend/postmaster/autovacuum.c
src/backend/utils/misc/guc.c
src/include/access/xact.h
src/include/replication/syncrep.h

index 503506f1f0d7cc9d5a8efc0f241f246474527020..55aee8791014e343e7ddf459e386399cee070ef3 100644 (file)
@@ -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)
        {
                /*
index 675bfced63c277bcc6554426698005620fefee29..619facc75260cf6b6d358ca9b8551b4dfeda939d 100644 (file)
@@ -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);
 
        /*
index 1f7a7d24f833d9f79e1d45021e7b62eca1df8001..2151fde36185612f43c3299e8e5db4c1f54a2e57 100644 (file)
@@ -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},
index 44101453445f0dc4dad60c460234af5ba6597ecb..8b60e8f163581eaca7a8b188c264a056afb93b43 100644 (file)
@@ -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;
 
index 696edccb120ec7898c5438b1445c360b160e335c..9022b96585536410f86d1eb657b5128974929a0a 100644 (file)
@@ -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