Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Gap Locking Question, PostgreSQL #1

Open
MicahLyle opened this issue Feb 13, 2020 · 2 comments
Open

Gap Locking Question, PostgreSQL #1

MicahLyle opened this issue Feb 13, 2020 · 2 comments

Comments

@MicahLyle
Copy link

Hi @pirate thanks for putting this on GitHub. I came across it today and it was really helpful.

One thing I've been looking into for a while but haven't definitively gotten the answer to:

https://pirate.github.io/django-concurrency-talk/#sql-gap-locking

It definitely seems like "Gap Locking" applies on MySQL with InnoDB. However, I couldn't find/figure out if it applies to PostgreSQL or not. Do you know?

@pirate
Copy link
Owner

pirate commented Feb 20, 2020

Not sure if it's doable in PG actually, the alternative is to do your own application-level advisory locking. Here are some links with more detail:

@MicahLyle
Copy link
Author

MicahLyle commented Feb 21, 2020

Thank you so much! My mentally proposed solution was actually to create a separate table because I had IDs from another service that were unique values. Then I'd essentially create records in that table with the unique ids, and then lock those for update. The upside of that idea is that those "lock rows" could also hold useful logging/introspection values in them in say ArrayFields, etc. and see like the last five spots that have accessed them (or however many), etc.

I may actually use that django-pglocks library that seems great!

I did also confirm Gap Locking doesn't work in PostgreSQL, at least with the settings I was using.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants