Comments (8)
@mceachen Hi Matthew, I was looking into this but have a few questions (First Time contributor, so bare with me :)
It looks like the pg_try_advisory
method of PostgresSQL does not support timeouts, see the documentation.
One idea is to make the implementation of the yield_with_lock method specific per database, i.e. move it to the respective database files. In this case then we can set a timeout for MySQL, which seems to be supported (see https://dev.mysql.com/doc/refman/5.7/en/miscellaneous-functions.html#function_get-lock) . But it feels like we are loosing genericity and introducing a more complex implementation. Is there anything i miss here? Thanks for any help/input :)
from with_advisory_lock.
Howdy, @serenaf! Per @mceachen's recommendations, I added activerecord 5.1 and both flavors of MySQL (< 5.7.5 and >= 5.7.5) to the testing matrix. Would you be able to help craft a failing test so that we can get started on resolving?
from with_advisory_lock.
@danielventulieri sorry, I don't know. This gem is being maintained by @seuros at this point, and I'll defer to his response.
from with_advisory_lock.
Sure!
from with_advisory_lock.
Cleaning out my open issues.
from with_advisory_lock.
Reopening-- @relwell, you're not on the hook for this. Anyone can submit a PR for it.
from with_advisory_lock.
@serenaf thanks for looking into this. Your link to MySQL's fundamental change to get_lock
(in a patch release, of course) is most unfortunate, and breaks this gem as it stands. So, good news that you highlighted that, bad news is there was something to highlight.
Just because Postgres doesn't support a timeout doesn't mean we can't support a timeout--we can do a polling retry with a fast-fail method (pg_try_advisory
) for the duration of the timeout.
To be honest I'm not using ruby (or rails) for any projects (not for 4 years now!), and I've been supporting my ruby projects because there are too many abandoned libraries out there. If you'd like to take a stab at a PR, though, I'm happy to review it and help you get it merged, but there should be tests added to the matrix for MySQL < 5.7.5 and >= 5.7.5, and ActiveRecord 5.1 as well (given that is the currently supported version).
from with_advisory_lock.
Hi @mceachen. I know I'm 4 years late, but what do you mean by "breaks this gem as it stands"? I've tested locally with multiple threads trying to access the lock and everything looks fine. Is this gem safe to use in production?
from with_advisory_lock.
Related Issues (20)
- Drop dependency on thread_safe HOT 3
- MySQL supports nested locks in >= 5.7.5
- Website in repo description goes to 404 HOT 1
- Build is failing in master branch HOT 1
- undefined method `with_advisory_lock' in Rails test environment HOT 6
- [Not a bug] Proper usage of with_advisory_lock
- Next planned release? HOT 4
- Rails 6 compatibility? HOT 2
- MiniTest warning about usage in tests HOT 1
- With_advisory_lock test with Multiple threads fails HOT 5
- advisory locks with connection pooling (pgbouncer) HOT 4
- Connection pool causing locks to be taken when they shouldn't HOT 1
- Lots of duplicate/unnecessary calls to `select get_version()` HOT 1
- PG Transactional locks not working on Rails 5.2 HOT 9
- Is the unique column name still necessary or does AR do the right thing now? HOT 5
- [Question] RDSProxy Usage HOT 2
- RFC: Turn off ActiveRecord caching within lock blocks HOT 7
- Why not raise exception when the lock couldn't be acquired in the given timeout? HOT 4
- any plans on supporting rails 7 ? HOT 2
- Using `with_advisory_lock!` HOT 7
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from with_advisory_lock.