[openstreetmap/openstreetmap-website] Lock changesets during a diff upload (PR #6379)

mmd notifications at github.com
Fri Sep 5 19:14:26 UTC 2025


mmd-osm left a comment (openstreetmap/openstreetmap-website#6379)

Here's the kind of change I've been testing locally. It moves both changeset consistency checking as well as DiffReader inside the exclusive changeset lock.

```ruby
diff --git a/app/controllers/api/changesets/uploads_controller.rb b/app/controllers/api/changesets/uploads_controller.rb
index ee9406d91..2afdd5e63 100644
--- a/app/controllers/api/changesets/uploads_controller.rb
+++ b/app/controllers/api/changesets/uploads_controller.rb
@@ -27,10 +27,10 @@ module Api
       # http://wiki.openstreetmap.org/wiki/OSM_Protocol_Version_0.6
       def create
         changeset = Changeset.find(params[:changeset_id])
-        check_changeset_consistency(changeset, current_user)
+        changeset.with_lock do
+          check_changeset_consistency(changeset, current_user)
 
-        diff_reader = DiffReader.new(request.raw_post, changeset)
-        Changeset.transaction do
+          diff_reader = DiffReader.new(request.raw_post, changeset)
           result = diff_reader.commit
           # the number of changes in this changeset has already been
           # updated and is visible in this transaction so we don't need
```



-- 
Reply to this email directly or view it on GitHub:
https://github.com/openstreetmap/openstreetmap-website/pull/6379#issuecomment-3259467563
You are receiving this because you are subscribed to this thread.

Message ID: <openstreetmap/openstreetmap-website/pull/6379/c3259467563 at github.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openstreetmap.org/pipermail/rails-dev/attachments/20250905/b136e292/attachment.htm>


More information about the rails-dev mailing list