v5-0002-This-recommendation-is-outdated-for-some-time-now.patch

application/octet-stream

Filename: v5-0002-This-recommendation-is-outdated-for-some-time-now.patch
Type: application/octet-stream
Part: 0
Message: Re: [PATCH] Clarify the behavior of the system when approaching XID wraparound

Patch

Format: format-patch
Series: patch v5-0002
Subject: 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.
File+
doc/src/sgml/maintenance.sgml 14 6
src/backend/access/transam/varsup.c 2 2
From 4633ec986fce07c22ca094212c86ca16d5c9c887 Mon Sep 17 00:00:00 2001
From: Pavel Borisov <pashkin.elfe@gmail.com>
Date: Tue, 4 Apr 2023 13:26:14 +0400
Subject: [PATCH v5 2/3] 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 b7254344ee0..66456b5e462 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 can't 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 bd27576bd58..f039c98cd09 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 can't 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 and drop stale replication slots.")));
 			else
 				ereport(ERROR,
 						(errcode(ERRCODE_PROGRAM_LIMIT_EXCEEDED),
 						 errmsg("database can't 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 and drop stale replication slots.")));
 		}
 		else if (TransactionIdFollowsOrEquals(xid, xidWarnLimit))
-- 
2.37.1 (Apple Git-137.1)