Default to log_lock_waits=on
authorPeter Eisentraut <peter@eisentraut.org>
Fri, 12 Sep 2025 05:57:06 +0000 (07:57 +0200)
committerPeter Eisentraut <peter@eisentraut.org>
Fri, 12 Sep 2025 05:57:06 +0000 (07:57 +0200)
If someone is stuck behind a lock for more than a second, that is
almost always a problem that is worth a log entry.

Author: Laurenz Albe <laurenz.albe@cybertec.at>
Reviewed-By: Michael Banck <mbanck@gmx.net>
Reviewed-By: Robert Haas <robertmhaas@gmail.com>
Reviewed-By: Christoph Berg <myon@debian.org>
Reviewed-By: Stephen Frost <sfrost@snowman.net>
Discussion: https://postgr.es/m/b8b8502915e50f44deb111bc0b43a99e2733e117.camel%40cybertec.at

doc/src/sgml/config.sgml
src/backend/storage/lmgr/proc.c
src/backend/utils/misc/guc_parameters.dat
src/backend/utils/misc/postgresql.conf.sample

index 2a3685f474a9658dabea29c781036659023a1820..3c33d5d0fbcae47126e1361d23305317b006c3b5 100644 (file)
@@ -7929,7 +7929,7 @@ log_line_prefix = '%m [%p] %q%u@%d/%a '
         Controls whether a log message is produced when a session waits
         longer than <xref linkend="guc-deadlock-timeout"/> to acquire a
         lock.  This is useful in determining if lock waits are causing
-        poor performance.  The default is <literal>off</literal>.
+        poor performance.  The default is <literal>on</literal>.
         Only superusers and users with the appropriate <literal>SET</literal>
         privilege can change this setting.
        </para>
index e9ef0fbfe32cb724744e2381fbe9c89561a35dbb..96f29aafc391edabe28518237be8b406c606766a 100644 (file)
@@ -60,7 +60,7 @@ int           LockTimeout = 0;
 int            IdleInTransactionSessionTimeout = 0;
 int            TransactionTimeout = 0;
 int            IdleSessionTimeout = 0;
-bool       log_lock_waits = false;
+bool       log_lock_waits = true;
 
 /* Pointer to this process's PGPROC struct, if any */
 PGPROC    *MyProc = NULL;
index 0da01627cfec153b130add95c08b4044bb24cb89..6bc6be13d2ad24fa84ab815fb634df7391717d52 100644 (file)
 { name => 'log_lock_waits', type => 'bool', context => 'PGC_SUSET', group => 'LOGGING_WHAT',
   short_desc => 'Logs long lock waits.',
   variable => 'log_lock_waits',
-  boot_val => 'false',
+  boot_val => 'true',
 },
 
 { name => 'log_lock_failures', type => 'bool', context => 'PGC_SUSET', group => 'LOGGING_WHAT',
index 26c0869356485f268ab11095eb9b60dcfcd9b236..c36fcb9ab6105115c38c888f6811e03255208fa1 100644 (file)
                    #        processes
                    #   %% = '%'
                    # e.g. '<%u%%%d> '
-#log_lock_waits = off          # log lock waits >= deadlock_timeout
+#log_lock_waits = o          # log lock waits >= deadlock_timeout
 #log_lock_failures = off       # log lock failures
 #log_recovery_conflict_waits = off # log standby recovery conflict waits
                    # >= deadlock_timeout