Suppress the Advisory Lock not implemented error in YSQL

PostgreSQL provides a means for creating locks that have application-defined meanings. These are called advisory locks, because the system does not enforce their use — it is up to the application to use them correctly.

Currently, YugabyteDB does not support advisory locks and you’ll get an error letting you know.

Example:

				
					yugabyte=# SELECT pg_advisory_lock(5);
ERROR:  advisory locks are not yet implemented
HINT:  See https://github.com/yugabyte/yugabyte-db/issues/3642. React with thumbs up to raise its priority
				
			

Here is the link to the github issue 3642 from the HINT above.

The good news is that there is a parameter named yb_silence_advisory_locks_not_supported_error which can be turned on to suppress the error message, allowing your application code to run with out fail when trying to create an advisory lock.

This parameter can be set at the universe, database, session and user levels.

Here is an example at the database level.

				
					yugabyte=# CREATE DATABASE test;
CREATE DATABASE

yugabyte=# ALTER DATABASE test SET yb_silence_advisory_locks_not_supported_error = on;
ALTER DATABASE

yugabyte=# \! ysqlsh -h 10.38.1.183 -d test -c "SELECT pg_advisory_lock(5);"
 pg_advisory_lock
------------------

(1 row)
				
			

Have Fun!

Visited my daughter in Knoxville, TN this weekend. Her neighbor turned their entire backyard into a dirt bike course!