4 ms·
> it just blocks until the lock is released normal Postgres locks have a https://postgresqlco.nf/doc/en/param/lock_timeout/ https://postgresqlco.nf/doc/en/para
by anentropic 5y ago
> it just blocks until the lock is released
normal Postgres locks have a https://postgresqlco.nf/doc/en/param/lock_timeout/ https://postgresqlco.nf/doc/en/param/lock_timeout/ which is max time a client will wait to acquire lock before returning an error instead
SELECT FOR UPDATE queries also accept NOWAIT keyword to return error immediately if locked
I would guess the former applies to advisory locks too. I think NOWAIT only applies to FOR UPDATE / FOR SHARE queries
But it looks like there is try_advisory_lock method https://www.postgresql.org/docs/current/functions-admin.html#FUNCTIONS-ADVISORY-LOCKS https://www.postgresql.org/docs/current/functions-admin.html... that does the equivalent
- 3pt14159 5y agoRight. Well, I guess I just think the article is worded confusingly then. Because when I read it I thought "wait, it doesn't error, it waits" and I think that's an important feature.
- anentropic 5y agoYes you can choose, either to wait until your configured timeout (and if you set it to 0 it will wait indefinitely) or error immediately