diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2010-07-03 20:43:58 +0000 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2010-07-03 20:43:58 +0000 |
commit | e76c1a0f4d2127f11c72c02b3d73a5dcb4517173 (patch) | |
tree | 7a81ef438a2ef591dda9f8cf1c9e4eecfc5082e7 /src/backend/storage/lmgr/proc.c | |
parent | e6a7416e28bacef6311be20375c8498b23faeb65 (diff) |
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.
Diffstat (limited to 'src/backend/storage/lmgr/proc.c')
-rw-r--r-- | src/backend/storage/lmgr/proc.c | 24 |
1 files changed, 13 insertions, 11 deletions
diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index d7eb8695038..2d77be0a34e 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/storage/lmgr/proc.c,v 1.219 2010/05/26 19:52:52 sriggs Exp $ + * $PostgreSQL: pgsql/src/backend/storage/lmgr/proc.c,v 1.220 2010/07/03 20:43:58 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -1627,12 +1627,13 @@ handle_sig_alarm(SIGNAL_ARGS) bool enable_standby_sig_alarm(TimestampTz now, TimestampTz fin_time, bool deadlock_only) { - TimestampTz deadlock_time = TimestampTzPlusMilliseconds(now, DeadlockTimeout); + TimestampTz deadlock_time = TimestampTzPlusMilliseconds(now, + DeadlockTimeout); if (deadlock_only) { /* - * Wake up at DeadlockTimeout only, then wait forever + * Wake up at deadlock_time only, then wait forever */ statement_fin_time = deadlock_time; deadlock_timeout_active = true; @@ -1641,7 +1642,7 @@ enable_standby_sig_alarm(TimestampTz now, TimestampTz fin_time, bool deadlock_on else if (fin_time > deadlock_time) { /* - * Wake up at DeadlockTimeout, then again at MaxStandbyDelay + * Wake up at deadlock_time, then again at fin_time */ statement_fin_time = deadlock_time; statement_fin_time2 = fin_time; @@ -1651,7 +1652,7 @@ enable_standby_sig_alarm(TimestampTz now, TimestampTz fin_time, bool deadlock_on else { /* - * Wake only at MaxStandbyDelay because its fairly soon + * Wake only at fin_time because its fairly soon */ statement_fin_time = fin_time; deadlock_timeout_active = false; @@ -1729,15 +1730,16 @@ CheckStandbyTimeout(void) if (deadlock_timeout_active) { /* - * We're still waiting when we reach DeadlockTimeout, so send out a request - * to have other backends check themselves for deadlock. Then continue - * waiting until MaxStandbyDelay. + * We're still waiting when we reach deadlock timeout, so send out + * a request to have other backends check themselves for + * deadlock. Then continue waiting until statement_fin_time, + * if that's set. */ SendRecoveryConflictWithBufferPin(PROCSIG_RECOVERY_CONFLICT_STARTUP_DEADLOCK); deadlock_timeout_active = false; /* - * Begin second waiting period to MaxStandbyDelay if required. + * Begin second waiting period if required. */ if (statement_timeout_active) { @@ -1748,8 +1750,8 @@ CheckStandbyTimeout(void) else { /* - * We've now reached MaxStandbyDelay, so ask all conflicts to leave, cos - * its time for us to press ahead with applying changes in recovery. + * We've now reached statement_fin_time, so ask all conflicts to + * leave, so we can press ahead with applying changes in recovery. */ SendRecoveryConflictWithBufferPin(PROCSIG_RECOVERY_CONFLICT_BUFFERPIN); } |