Description:
Enabling the 'log_lock_waits' flag for a PostgreSQL instance creates a log for any session waits that take longer than the allotted 'deadlock_timeout' time to acquire a lock.
Rationale:
The deadlock timeout defines the time to wait on a lock before checking for any conditions. Frequent run overs on deadlock timeout can be an indication of an underlying issue. Logging such waits on locks by enabling the 'log_lock_waits' flag can be used to identify poor performance due to locking delays or if a specially-crafted SQL is attempting to starve resources through holding locks for excessive amounts of time. This recommendation is applicable to PostgreSQL database instances.
From Console:
From Command Line:
gcloud sql instances list
gcloud sql instances patch INSTANCE_NAME --database-flags log_lock_waits=on
Note: This command will overwrite all database flags previously set. To keep those and add new ones, include the values for all flags to be set on the instance; any flag not specifically included is set to its default value. For flags that do not take a value, specify the flag name followed by an equals sign ("=").
.