Skip to content

Commit 93eb619

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 23c75b5 commit 93eb619

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
@@ -924,6 +924,13 @@ check_synchronous_standby_names(char **newval, void **extra, GucSource source)
924924
return false;
925925
}
926926

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

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