WithAdvisoryLock is silently ignoring the timeout_seconds parameter when blocking option is set to true. There's no warning or indication. The only clue is in-code comment:
timeout_seconds is accepted for compatibility but ignored - PostgreSQL doesn't support native timeouts with pg_try_advisory_lock, requiring Ruby-level polling instead
Postgres does support timeouts if session-level lock_timeout is set, which is what IMO should be used when blocking is used in combination with a timeout. Also, blocking: true && timeout_seconds&.zero? should use the try_ family of functions (effectively blocking should be ignored if timeout is explicitly zero).
If this is not possible or wanted, consider at least adding a warn statement if timeout is specified along with blocking.
WithAdvisoryLock is silently ignoring the
timeout_secondsparameter whenblockingoption is set totrue. There's no warning or indication. The only clue is in-code comment:Postgres does support timeouts if session-level
lock_timeoutis set, which is what IMO should be used when blocking is used in combination with a timeout. Also, blocking: true && timeout_seconds&.zero? should use thetry_family of functions (effectively blocking should be ignored if timeout is explicitly zero).If this is not possible or wanted, consider at least adding a
warnstatement if timeout is specified along withblocking.