diff --git a/src/backend/replication/syncrep.c b/src/backend/replication/syncrep.c
index cb6b5e5..9c803c8 100644
--- a/src/backend/replication/syncrep.c
+++ b/src/backend/replication/syncrep.c
@@ -68,6 +68,7 @@
 #include "storage/proc.h"
 #include "tcop/tcopprot.h"
 #include "utils/builtins.h"
+#include "utils/memutils.h"
 #include "utils/ps_status.h"
 
 /* User-settable parameters for sync rep */
@@ -1023,6 +1024,38 @@ check_synchronous_standby_names(char **newval, void **extra, GucSource source)
 }
 
 void
+assign_synchronous_standby_names(const char *newval, void *extra)
+{
+	if (newval != NULL && newval[0] != '\0')
+	{
+		int	parse_rc PG_USED_FOR_ASSERTS_ONLY;
+
+		/*
+		 * check_synchronous_standby_names() verifies the setting value of
+		 * synchronous_standby_names before this function is called. So
+		 * syncrep_yyparse() must not cause an error here.
+		 */
+
+		MemoryContextSwitchTo(TopMemoryContext);
+
+		syncrep_scanner_init(newval);
+		parse_rc = syncrep_yyparse();
+		Assert(parse_rc == 0);
+		syncrep_scanner_finish();
+
+		if (SyncRepConfig)
+		{
+			SyncRepFreeConfig(SyncRepConfig);
+			SyncRepConfig = NULL;
+		}
+
+		SyncRepConfig = syncrep_parse_result;
+	}
+
+	return;
+}
+
+void
 assign_synchronous_commit(int newval, void *extra)
 {
 	switch (newval)
diff --git a/src/backend/replication/walsender.c b/src/backend/replication/walsender.c
index e4a0119..a9c982b 100644
--- a/src/backend/replication/walsender.c
+++ b/src/backend/replication/walsender.c
@@ -2780,23 +2780,12 @@ pg_stat_get_wal_senders(PG_FUNCTION_ARGS)
 	MemoryContextSwitchTo(oldcontext);
 
 	/*
-	 * Allocate and update the config data of synchronous replication,
-	 * and then get the currently active synchronous standbys.
+	 * Get the currently active synchronous standbys.
 	 */
-	SyncRepUpdateConfig();
 	LWLockAcquire(SyncRepLock, LW_SHARED);
 	sync_standbys = SyncRepGetSyncStandbys(NULL);
 	LWLockRelease(SyncRepLock);
 
-	/*
-	 * Free the previously-allocated config data because a backend
-	 * no longer needs it. The next call of this function needs to
-	 * allocate and update the config data newly because the setting
-	 * of sync replication might be changed between the calls.
-	 */
-	SyncRepFreeConfig(SyncRepConfig);
-	SyncRepConfig = NULL;
-
 	for (i = 0; i < max_wal_senders; i++)
 	{
 		WalSnd *walsnd = &WalSndCtl->walsnds[i];
diff --git a/src/backend/utils/misc/guc.c b/src/backend/utils/misc/guc.c
index a070500..01df9d3 100644
--- a/src/backend/utils/misc/guc.c
+++ b/src/backend/utils/misc/guc.c
@@ -3463,7 +3463,7 @@ static struct config_string ConfigureNamesString[] =
 		},
 		&SyncRepStandbyNames,
 		"",
-		check_synchronous_standby_names, NULL, NULL
+		check_synchronous_standby_names, assign_synchronous_standby_names, NULL
 	},
 
 	{
diff --git a/src/include/replication/syncrep.h b/src/include/replication/syncrep.h
index 14b5664..59c2493 100644
--- a/src/include/replication/syncrep.h
+++ b/src/include/replication/syncrep.h
@@ -66,6 +66,7 @@ extern void SyncRepFreeConfig(SyncRepConfigData *config);
 extern void SyncRepUpdateSyncStandbysDefined(void);
 
 extern bool check_synchronous_standby_names(char **newval, void **extra, GucSource source);
+extern void assign_synchronous_standby_names(const char *newval, void *extra);
 extern void assign_synchronous_commit(int newval, void *extra);
 
 /*
