with_advisory_lock
with_advisory_lock copied to clipboard
Use built-in wait and timeout functionality if the database engine supports it
This is regarding issue #80
- Added support for built-in wait and timeout functionality if the database engine supports it.
- Unfortunately, PostgreSQL doesn't provide a function to wait for a lock with a specific timeout easily. For now, it will still use the existing Ruby-based sleep loop implementation if a timeout is specified. There are ways to accomplish this with a function, but that has it's own drawbacks in terms of SQL query load
- Added more test coverage regarding waiting for locks and transaction support with and without timeout.
The only issue I see for PostgreSQL and using pg_advisory_lock is that it's unclear if the PostgreSQL client settings statement_timeout and lock_timeout apply, which would mean that it may not infinitely wait for the lock to be acquired and rather throw a PostgreSQL error.