From bca8b7f16a3e720794cb0afbdb3733be4f8d9c2c Mon Sep 17 00:00:00 2001 From: Simon Riggs Date: Wed, 16 Feb 2011 19:29:37 +0000 Subject: Hot Standby feedback for avoidance of cleanup conflicts on standby. Standby optionally sends back information about oldestXmin of queries which is then checked and applied to the WALSender's proc->xmin. GetOldestXmin() is modified slightly to agree with GetSnapshotData(), so that all backends on primary include WALSender within their snapshots. Note this does nothing to change the snapshot xmin on either master or standby. Feedback piggybacks on the standby reply message. vacuum_defer_cleanup_age is no longer used on standby, though parameter still exists on primary, since some use cases still exist. Simon Riggs, review comments from Fujii Masao, Heikki Linnakangas, Robert Haas --- doc/src/sgml/config.sgml | 20 +++++++++++++++++ doc/src/sgml/high-availability.sgml | 44 ++++++++++++++++++------------------- 2 files changed, 41 insertions(+), 23 deletions(-) (limited to 'doc/src') diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml index 9505caf47a2..cee09c76815 100644 --- a/doc/src/sgml/config.sgml +++ b/doc/src/sgml/config.sgml @@ -2006,6 +2006,10 @@ SET ENABLE_SEQSCAN TO OFF; This parameter can only be set in the postgresql.conf file or on the server command line. + + You should also consider setting hot_standby_feedback + as an alternative to using this parameter. + @@ -2121,6 +2125,22 @@ SET ENABLE_SEQSCAN TO OFF; + + hot_standby_feedback (boolean) + + hot_standby_feedback configuration parameter + + + + Specifies whether or not a hot standby will send feedback to the primary + about queries currently executing on the standby. This parameter can + be used to eliminate query cancels caused by cleanup records, though + it can cause database bloat on the primary for some workloads. + The default value is off. + + + + diff --git a/doc/src/sgml/high-availability.sgml b/doc/src/sgml/high-availability.sgml index 368c68867af..37ba43b5fd7 100644 --- a/doc/src/sgml/high-availability.sgml +++ b/doc/src/sgml/high-availability.sgml @@ -1483,23 +1483,6 @@ if (!triggered) on the primary, if it delays application of WAL records. - - The most common reason for conflict between standby queries and WAL replay - is early cleanup. Normally, PostgreSQL allows - cleanup of old row versions when there are no transactions that need to - see them to ensure correct visibility of data according to MVCC rules. - However, this rule can only be applied for transactions executing on the - master. So it is possible that cleanup on the master will remove row - versions that are still visible to a transaction on the standby. - - - - Experienced users should note that both row version cleanup and row version - freezing will potentially conflict with standby queries. Running a manual - VACUUM FREEZE is likely to cause conflicts even on tables with - no updated or deleted rows. - - Once the delay specified by max_standby_archive_delay or max_standby_streaming_delay has been exceeded, conflicting @@ -1526,6 +1509,23 @@ if (!triggered) as a result of being unable to keep up with a heavy update load. + + The most common reason for conflict between standby queries and WAL replay + is early cleanup. Normally, PostgreSQL allows + cleanup of old row versions when there are no transactions that need to + see them to ensure correct visibility of data according to MVCC rules. + However, this rule can only be applied for transactions executing on the + master. So it is possible that cleanup on the master will remove row + versions that are still visible to a transaction on the standby. + + + + Experienced users should note that both row version cleanup and row version + freezing will potentially conflict with standby queries. Running a manual + VACUUM FREEZE is likely to cause conflicts even on tables with + no updated or deleted rows. + + Users should be clear that tables that are regularly and heavily updated on the primary server will quickly cause cancellation of longer running @@ -1537,12 +1537,10 @@ if (!triggered) Remedial possibilities exist if the number of standby-query cancellations - is found to be unacceptable. The first option is to connect to the - primary server and keep a query active for as long as needed to - run queries on the standby. This prevents VACUUM from removing - recently-dead rows and so cleanup conflicts do not occur. - This could be done using and - pg_sleep(), or via other mechanisms. If you do this, you + is found to be unacceptable. The first option is to set the parameter + hot_standby_feedback, which prevents VACUUM from + removing recently-dead rows and so cleanup conflicts do not occur. + If you do this, you should note that this will delay cleanup of dead rows on the primary, which may result in undesirable table bloat. However, the cleanup situation will be no worse than if the standby queries were running -- cgit v1.2.3