Comments (10)
You are not guaranteed to see all comments.
- user A reopens the note
- user B closes the note
- user A reopens the note again
- user B deletes their account - now you won't see (2), you'll see two reopens
from openstreetmap-website.
Hi Anton, Thanks for your example, but this is not the case. The date/time is the same for the 2 "reopen" actions, with the same user (vramirez) who still has an active account.
from openstreetmap-website.
Ok, the two reopens at 2013-10-05 15:13:48 UTC probably didn't happen as I described, but that's still a possible scenario.
Maybe it's possible to reopen a note twice if the requests are done quick enough. The api code didn't change much since it was added in d74d4f8.
from openstreetmap-website.
Therefore, you confirm that this is a bug that the API has, which does not check the current status when a new status arrives, and it is the same.
I have found the other case, close a closed note: 19523
from openstreetmap-website.
I have found other interesting cases:
- 4 consecutive closes https://api.openstreetmap.org/api/0.6/notes/1258997 in 4-minute window.
- Different users closing the note https://api.openstreetmap.org/api/0.6/notes/365932
I put the complete list here: https://wiki.openstreetmap.org/wiki/User:Angoca/invalidTransitions
from openstreetmap-website.
Maybe it's possible to reopen a note twice if the requests are done quick enough
At least checking the current status of a note (Note.find_by_id(id)
... raise OSM::APINoteAlreadyOpenError.new(@note) unless @note.closed?
) is done without exclusive or optimistic locking (based on version numbers).
If multiple API requests for the same note are processed at the same time, such duplicates can occur.
from openstreetmap-website.
There is a check for duplicate closes (https://github.com/openstreetmap/openstreetmap-website/blob/master/app/controllers/api/notes_controller.rb#L181) and has been since ae27f7a in February 2013 but as it is at the application layer two closes very close together might still make it to the database because both might pass the check before either one has made the change as the check is not inside a transaction and there is no constraint in the database that would block it.
from openstreetmap-website.
I guess something like this should do then?
# Close the note and add a comment
Note.transaction do
# Find the note and check it is valid
@note = Note.lock.find_by(:id => id)
raise OSM::APINotFoundError unless @note
raise OSM::APIAlreadyDeletedError.new("note", @note.id) unless @note.visible?
raise OSM::APINoteAlreadyClosedError, @note if @note.closed?
@note.close
add_comment(@note, comment, "closed")
end
from openstreetmap-website.
I doubt an explicit lock is needed or a good idea - a transaction on it's own should be enough surely?
from openstreetmap-website.
Try to add a "sleep 10" right before @note.close
and then test in two different browser windows. Without explicit locking you can resolve the note twice, with locking in place the second resolve attempt fails with an error message "The note xxx was closed at yyy UTC".
lock will add "FOR UPDATE" when fetching details for one note only. It's not some sort of table lock.
SELECT "notes".* FROM "notes" WHERE "notes"."id" = $1 LIMIT $2 FOR UPDATE [["id", 4], ["LIMIT", 1]]
It would probably be better to use optimistic locking in this case, since conflicts should be extremely rare. On the other hand, our Note model doesn't have a lock_version field, which is needed according to https://api.rubyonrails.org/classes/ActiveRecord/Locking/Optimistic.html
from openstreetmap-website.
Related Issues (20)
- Mobile: Hidden close history tab button HOT 5
- Map Data checkbox: perhaps use toggle slider instead HOT 1
- Allow blocks to be hidden HOT 8
- Better handling of version links for an unversioned element view HOT 1
- Add examples to Display Name HOT 5
- Searches for latitudes or longitudes between 1 and -1 result in invalid E-notation numbers HOT 1
- Geocoded address missing from the OSM notes RSS feed HOT 6
- Missing American English localization HOT 10
- Third party logins fail to preserve the referer URL HOT 4
- Unable to Run ESLint Inside Docker Container HOT 2
- Retire activerecord-import gem?
- 'Show address' no longer adds coords to search box HOT 2
- [API] Can not GET/DELETE a preference with a dot in its name. Ex: HOT 1
- Make the Multi fetch response more friendly for hidden versions of objects HOT 3
- Multi fetch for objects histories HOT 9
- NodeJS versions are out of sync again HOT 6
- Add Rate limiting for diary comments HOT 5
- 'GPX Import success' e-mail contains only HTML and not a text part HOT 3
- Facebook login keeps asking to confirm login HOT 1
- Clicking coordinates doesn't pan to location anymore? HOT 10
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 openstreetmap-website.