v4-0002-Don-t-recommend-running-VACUUM-in-a-single-user-m.patch

application/octet-stream

Filename: v4-0002-Don-t-recommend-running-VACUUM-in-a-single-user-m.patch
Type: application/octet-stream
Part: 1
Message: Re: [PATCH] Clarify the behavior of the system when approaching XID wraparound

Patch

Format: format-patch
Series: patch v4-0002
Subject: Don't recommend running VACUUM in a single-user mode when reaching xidStopLimit
File+
doc/src/sgml/maintenance.sgml 14 6
src/backend/access/transam/varsup.c 2 2
From dce05503162c274b5496cde5b2e7cefcb78452ba Mon Sep 17 00:00:00 2001
From: Aleksander Alekseev <aleksander@timescale.com>
Date: Mon, 16 Jan 2023 15:37:12 +0300
Subject: [PATCH v4 2/3] Don't recommend running VACUUM in a single-user mode
 when reaching xidStopLimit

This recommendation is outdated for some time now. A regular VACUUM
works just fine. Additionally add an explicit note against using a single-user
mode for people who may potentially miss this change.

Author: Aleksander Alekseev
Reported-by: Hannu Krosing
Reviewed-by: John Naylor
Discussion: https://postgr.es/m/CAJ7c6TM2D277U2wH8X78kg8pH3tdUqebV3_JCJqAkYQFHCFzeg@mail.gmail.com
Discussion: https://postgr.es/m/CAMT0RQTmRj_Egtmre6fbiMA9E2hM3BsLULiV8W00stwa3URvzA%40mail.gmail.com
---
 doc/src/sgml/maintenance.sgml       | 20 ++++++++++++++------
 src/backend/access/transam/varsup.c |  4 ++--
 2 files changed, 16 insertions(+), 8 deletions(-)

diff --git a/doc/src/sgml/maintenance.sgml b/doc/src/sgml/maintenance.sgml
index 2a902e422c..f0d913c94f 100644
--- a/doc/src/sgml/maintenance.sgml
+++ b/doc/src/sgml/maintenance.sgml
@@ -668,7 +668,7 @@ HINT:  To prevent entering read-only mode, execute a database-wide VACUUM in tha
 
 <programlisting>
 ERROR:  database is not accepting commands that generate new XIDs to avoid wraparound data loss in database "mydb"
-HINT:  Stop the postmaster and vacuum that database in single-user mode.
+HINT:  VACUUM that database.
 </programlisting>
 
     In this condition any transactions already started can continue.
@@ -676,13 +676,21 @@ HINT:  Stop the postmaster and vacuum that database in single-user mode.
 
     The three-million-transaction safety margin exists to let the
     administrator recover without data loss, by manually executing the
-    required <command>VACUUM</command> commands.  However
-    the only way to do this is to stop the server and start the server in single-user
-    mode to execute <command>VACUUM</command>. See the
-    <xref linkend="app-postgres"/> reference page for details about using
-    single-user mode.
+    required <command>VACUUM</command> commands.
    </para>
 
+   <note>
+    <para>
+     Previously it was required to stop the postmaster and
+     <command>VACUUM</command> the database in a single-user mode. There is no
+     need to use a single-user mode anymore unless the resolution needs to be
+     speeded up by performing <command>TRUNCATE</command> or
+     <command>DROP</command>. Except for this scenario it's strongly advised
+     against using a single-user mode: it requires downtime, can't be monitored,
+     disables replication, disables safeguards against wraparound, etc.
+    </para>
+   </note>
+
    <sect3 id="vacuum-for-multixact-wraparound">
     <title>Multixacts and Wraparound</title>
 
diff --git a/src/backend/access/transam/varsup.c b/src/backend/access/transam/varsup.c
index 485d8ebf81..ef1f211d32 100644
--- a/src/backend/access/transam/varsup.c
+++ b/src/backend/access/transam/varsup.c
@@ -128,14 +128,14 @@ GetNewTransactionId(bool isSubXact)
 						(errcode(ERRCODE_PROGRAM_LIMIT_EXCEEDED),
 						 errmsg("database is not accepting commands that generate new XIDs to avoid wraparound data loss in database \"%s\"",
 								oldest_datname),
-						 errhint("Stop the postmaster and vacuum that database in single-user mode.\n"
+						 errhint("VACUUM that database.\n"
 								 "You might also need to commit or roll back old prepared transactions, or drop stale replication slots.")));
 			else
 				ereport(ERROR,
 						(errcode(ERRCODE_PROGRAM_LIMIT_EXCEEDED),
 						 errmsg("database is not accepting commands that generate new XIDs to avoid wraparound data loss in database with OID %u",
 								oldest_datoid),
-						 errhint("Stop the postmaster and vacuum that database in single-user mode.\n"
+						 errhint("VACUUM that database.\n"
 								 "You might also need to commit or roll back old prepared transactions, or drop stale replication slots.")));
 		}
 		else if (TransactionIdFollowsOrEquals(xid, xidWarnLimit))
-- 
2.39.2