Skip to content

Commit b8bb8db

Browse files
committed
More synchronous replication tweaks.
SyncRepRequested() must check not only the value of the synchronous_replication GUC but also whether max_wal_senders > 0. Otherwise, we might end up waiting for sync rep even when there's no possibility of a standby ever managing to connect. There are some existing cross-checks to prevent this, but they're not quite sufficient: the user can start the server with max_wal_senders=0, synchronous_standby_names='', and synchronous_replication=off and then subsequent make synchronous_standby_names not empty using pg_ctl reload, and then SET synchronous_standby=on, leading to an indefinite hang. Along the way, rename the global variable for the synchronous_replication GUC to match the name of the GUC itself, for clarity. Report by Fujii Masao, though I didn't use his patch.
1 parent e397d2e commit b8bb8db

File tree

3 files changed

+5
-4
lines changed

3 files changed

+5
-4
lines changed

src/backend/replication/syncrep.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@
6262
#include "utils/ps_status.h"
6363

6464
/* User-settable parameters for sync rep */
65-
bool sync_rep_mode = false; /* Only set in user backends */
65+
bool synchronous_replication = false; /* Only set in user backends */
6666
char *SyncRepStandbyNames;
6767

6868
static bool sync_standbys_defined = false; /* Is there at least one name? */

src/backend/utils/misc/guc.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -759,7 +759,7 @@ static struct config_bool ConfigureNamesBool[] =
759759
gettext_noop("Requests synchronous replication."),
760760
NULL
761761
},
762-
&sync_rep_mode,
762+
&synchronous_replication,
763763
false, NULL, NULL
764764
},
765765
{

src/include/replication/syncrep.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@
1919
#include "storage/spin.h"
2020
#include "utils/guc.h"
2121

22-
#define SyncRepRequested() (sync_rep_mode)
22+
#define SyncRepRequested() \
23+
(synchronous_replication && max_wal_senders > 0)
2324

2425
/* syncRepState */
2526
#define SYNC_REP_NOT_WAITING 0
@@ -28,7 +29,7 @@
2829
#define SYNC_REP_MUST_DISCONNECT 3
2930

3031
/* user-settable parameters for synchronous replication */
31-
extern bool sync_rep_mode;
32+
extern bool synchronous_replication;
3233
extern char *SyncRepStandbyNames;
3334

3435
/* called by user backend */

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy