From e76c1a0f4d2127f11c72c02b3d73a5dcb4517173 Mon Sep 17 00:00:00 2001 From: Tom Lane Date: Sat, 3 Jul 2010 20:43:58 +0000 Subject: Replace max_standby_delay with two parameters, max_standby_archive_delay and max_standby_streaming_delay, and revise the implementation to avoid assuming that timestamps found in WAL records can meaningfully be compared to clock time on the standby server. Instead, the delay limits are compared to the elapsed time since we last obtained a new WAL segment from archive or since we were last "caught up" to WAL data arriving via streaming replication. This avoids problems with clock skew between primary and standby, as well as other corner cases that the original coding would misbehave in, such as the primary server having significant idle time between transactions. Per my complaint some time ago and considerable ensuing discussion. Do some desultory editing on the hot standby documentation, too. --- src/backend/utils/misc/guc.c | 34 ++++++++++++++++++++++------------ 1 file changed, 22 insertions(+), 12 deletions(-) (limited to 'src/backend/utils/misc/guc.c') diff --git a/src/backend/utils/misc/guc.c b/src/backend/utils/misc/guc.c index 73305486569..f2caad2cd9a 100644 --- a/src/backend/utils/misc/guc.c +++ b/src/backend/utils/misc/guc.c @@ -10,7 +10,7 @@ * Written by Peter Eisentraut . * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/utils/misc/guc.c,v 1.557 2010/06/25 13:11:25 sriggs Exp $ + * $PostgreSQL: pgsql/src/backend/utils/misc/guc.c,v 1.558 2010/07/03 20:43:58 tgl Exp $ * *-------------------------------------------------------------------- */ @@ -57,6 +57,7 @@ #include "postmaster/walwriter.h" #include "replication/walsender.h" #include "storage/bufmgr.h" +#include "storage/standby.h" #include "storage/fd.h" #include "tcop/tcopprot.h" #include "tsearch/ts_cache.h" @@ -116,7 +117,6 @@ extern char *default_tablespace; extern char *temp_tablespaces; extern bool synchronize_seqscans; extern bool fullPageWrites; -extern int vacuum_defer_cleanup_age; extern int ssl_renegotiation_limit; #ifdef TRACE_SORT @@ -1373,6 +1373,26 @@ static struct config_int ConfigureNamesInt[] = 1000, 1, INT_MAX / 1000, NULL, NULL }, + { + {"max_standby_archive_delay", PGC_SIGHUP, WAL_STANDBY_SERVERS, + gettext_noop("Sets the maximum delay before canceling queries when a hot standby server is processing archived WAL data."), + NULL, + GUC_UNIT_MS + }, + &max_standby_archive_delay, + 30 * 1000, -1, INT_MAX / 1000, NULL, NULL + }, + + { + {"max_standby_streaming_delay", PGC_SIGHUP, WAL_STANDBY_SERVERS, + gettext_noop("Sets the maximum delay before canceling queries when a hot standby server is processing streamed WAL data."), + NULL, + GUC_UNIT_MS + }, + &max_standby_streaming_delay, + 30 * 1000, -1, INT_MAX / 1000, NULL, NULL + }, + /* * Note: MaxBackends is limited to INT_MAX/4 because some places compute * 4*MaxBackends without any overflow check. This check is made in @@ -1392,16 +1412,6 @@ static struct config_int ConfigureNamesInt[] = 100, 1, INT_MAX / 4, assign_maxconnections, NULL }, - { - {"max_standby_delay", PGC_SIGHUP, WAL_STANDBY_SERVERS, - gettext_noop("Sets the maximum delay to avoid conflict processing on hot standby servers."), - NULL, - GUC_UNIT_MS - }, - &MaxStandbyDelay, - 30 * 1000, -1, INT_MAX / 1000, NULL, NULL - }, - { {"superuser_reserved_connections", PGC_POSTMASTER, CONN_AUTH_SETTINGS, gettext_noop("Sets the number of connection slots reserved for superusers."), -- cgit v1.2.3