From d1e51b531a80eb80a6d8ae17a78577ee98d641a0 Mon Sep 17 00:00:00 2001
From: Wang Wei <wangw.fnst@fujitsu.com>
Date: Wed, 15 Feb 2023 15:25:59 +0800
Subject: [PATCH v2] Fix the description of shared lock table size and shared
 predicate lock table size

---
 doc/src/sgml/config.sgml            |  6 ++++++
 src/backend/utils/misc/guc_tables.c | 10 ++++++----
 2 files changed, 12 insertions(+), 4 deletions(-)

diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml
index ecd9aa73ef..d134988dfc 100644
--- a/doc/src/sgml/config.sgml
+++ b/doc/src/sgml/config.sgml
@@ -10150,6 +10150,9 @@ dynamic_library_path = 'C:\tools\postgresql;H:\my_project\lib;$libdir'
         The shared lock table tracks locks on
         <varname>max_locks_per_transaction</varname> * (<xref
         linkend="guc-max-connections"/> + <xref
+        linkend="guc-autovacuum-max-workers"/> + 1 + <xref
+        linkend="guc-max-worker-processes"/> + <xref
+        linkend="guc-max-wal-senders"/> + <xref
         linkend="guc-max-prepared-transactions"/>) objects (e.g.,  tables);
         hence, no more than this many distinct objects can be locked at
         any one time.  This parameter controls the average number of object
@@ -10182,6 +10185,9 @@ dynamic_library_path = 'C:\tools\postgresql;H:\my_project\lib;$libdir'
         The shared predicate lock table tracks locks on
         <varname>max_pred_locks_per_transaction</varname> * (<xref
         linkend="guc-max-connections"/> + <xref
+        linkend="guc-autovacuum-max-workers"/> + 1 + <xref
+        linkend="guc-max-worker-processes"/> + <xref
+        linkend="guc-max-wal-senders"/> + <xref
         linkend="guc-max-prepared-transactions"/>) objects (e.g., tables);
         hence, no more than this many distinct objects can be locked at
         any one time.  This parameter controls the average number of object
diff --git a/src/backend/utils/misc/guc_tables.c b/src/backend/utils/misc/guc_tables.c
index 1c0583fe26..1460ca2f8f 100644
--- a/src/backend/utils/misc/guc_tables.c
+++ b/src/backend/utils/misc/guc_tables.c
@@ -2571,8 +2571,9 @@ struct config_int ConfigureNamesInt[] =
 		{"max_locks_per_transaction", PGC_POSTMASTER, LOCK_MANAGEMENT,
 			gettext_noop("Sets the maximum number of locks per transaction."),
 			gettext_noop("The shared lock table is sized on the assumption that "
-						 "at most max_locks_per_transaction * max_connections distinct "
-						 "objects will need to be locked at any one time.")
+						 "at most max_locks_per_transaction * (max_connections + autovacuum_max_workers + 1 "
+						 "+ max_worker_processes + max_wal_senders + max_prepared_transactions) "
+						 "distinct objects will need to be locked at any one time.")
 		},
 		&max_locks_per_xact,
 		64, 10, INT_MAX,
@@ -2583,8 +2584,9 @@ struct config_int ConfigureNamesInt[] =
 		{"max_pred_locks_per_transaction", PGC_POSTMASTER, LOCK_MANAGEMENT,
 			gettext_noop("Sets the maximum number of predicate locks per transaction."),
 			gettext_noop("The shared predicate lock table is sized on the assumption that "
-						 "at most max_pred_locks_per_transaction * max_connections distinct "
-						 "objects will need to be locked at any one time.")
+						 "at most max_pred_locks_per_transaction * (max_connections + autovacuum_max_workers + 1 "
+						 "+ max_worker_processes + max_wal_senders + max_prepared_transactions) "
+						 "distinct objects will need to be locked at any one time.")
 		},
 		&max_predicate_locks_per_xact,
 		64, 10, INT_MAX,
-- 
2.39.1.windows.1

