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

Commit 6c75fb6

Browse files
committed
Ensure that num_sync is greater than zero in synchronous_standby_names.
Previously num_sync could be set to zero and this setting caused an assertion failure. This means that multiple synchronous standbys code should assume that num_sync is greater than zero. Also setting num_sync to zero is nonsense because it's basically the configuration for synchronous replication. If users want not to make transaction commits wait for any standbys, synchronous_standby_names should be emptied to disable synchronous replication instead of setting num_sync to zero. This patch forbids users from setting num_sync to zero in synchronous_standby_names. If zero is specified, an error will happen during processing the parameter settings. Back-patch to 9.6 where multiple synchronous standbys feature was added. Patch by me. Reviewed by Tom Lane. Discussion: <CAHGQGwHWB3izc6cXuFLh5kOcAbFXaRhhgwd-X5PeN9TEjxqXwg@mail.gmail.com>
1 parent 6f73455 commit 6c75fb6

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

src/backend/replication/syncrep.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -922,6 +922,13 @@ check_synchronous_standby_names(char **newval, void **extra, GucSource source)
922922
return false;
923923
}
924924

925+
if (syncrep_parse_result->num_sync <= 0)
926+
{
927+
GUC_check_errmsg("number of synchronous standbys (%d) must be greater than zero",
928+
syncrep_parse_result->num_sync);
929+
return false;
930+
}
931+
925932
/* GUC extra value must be malloc'd, not palloc'd */
926933
pconf = (SyncRepConfigData *)
927934
malloc(syncrep_parse_result->config_size);

0 commit comments

Comments
 (0)