[openstreetmap/openstreetmap-website] Lock changesets during a diff upload (PR #6379)
Andy Allan
notifications at github.com
Wed Oct 8 16:58:42 UTC 2025
gravitystorm left a comment (openstreetmap/openstreetmap-website#6379)
I'm not very good with database locks, but I have two questions:
```ruby
changeset = Changeset.lock.find(params[:changeset_id])
```
Is this different from `changeset = Changeset.find(params[:changeset_id]).lock!` ? As far as I can tell from the docs, it's the same thing, but we use the `.lock!` variant elsewhere. If they are indeed identical, then I'd prefer to use the `.lock!` variant here, since that makes slightly easier to understand that it's the changeset being locked, and not e.g. the whole `Changeset` table.
Second question, in #6366 the "safe navigation operator" was used, e.g. `node.changeset&.lock!`. I found that surprising, since taking a lock is generally not optional! Is this deliberate, or is it a side-effect of taking the lock too early on e.g. should the lock be taken after the code that validates the changeset exists? Or is there something else there about locks that I don't understand?
--
Reply to this email directly or view it on GitHub:
https://github.com/openstreetmap/openstreetmap-website/pull/6379#issuecomment-3382454762
You are receiving this because you are subscribed to this thread.
Message ID: <openstreetmap/openstreetmap-website/pull/6379/c3382454762 at github.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openstreetmap.org/pipermail/rails-dev/attachments/20251008/e3a531f4/attachment-0001.htm>
More information about the rails-dev
mailing list