From 7ff56f0b9b68541a2403175a29f2a179d4ecb3c8 Mon Sep 17 00:00:00 2001 From: Aleksander Alekseev Date: Mon, 16 Jan 2023 15:37:12 +0300 Subject: [PATCH v6 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, Pavel Borisov 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..e6b24f3258 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 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: Execute a database-wide VACUUM in that database. 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 VACUUM commands. However - the only way to do this is to stop the server and start the server in single-user - mode to execute VACUUM. See the - reference page for details about using - single-user mode. + required VACUUM commands. + + + Previously it was required to stop the postmaster and + VACUUM 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 TRUNCATE or + DROP. 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. + + + Multixacts and Wraparound diff --git a/src/backend/access/transam/varsup.c b/src/backend/access/transam/varsup.c index 485d8ebf81..667da0fd64 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("Execute a database-wide VACUUM in 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("Execute a database-wide VACUUM in 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.40.0