-
Notifications
You must be signed in to change notification settings - Fork 4
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
Concurent Requests for same User #4
Comments
What do you mean with transaction over the whole process? Anyway, regarding the cron, the |
I mean something like the following (very ugly pseudocode, mixing SQL and php:
In this scenario the Database enforces that only one process can update a user at every given time. As mysql cant handle nested transactions the existing transactions would have to be rewritten using checkpoints with "SAVEPOINT name" and "ROLLBACK TO name" The problem I meant with the update_incomplete_statistics.php is that while it is running the user could send a new request (or multiple of them) and it would be processed in parallel doing unnecessary work. |
The code above never analse users not in the database as it is the same as a skip over an user in processing, so that have to be checked first. An alternative would be to just let the transaction wait on the lock to be released (remove SKIP LOCKED) but this would lead to many php processes waiting for the analyse step to be finished in the worst case, and if the OSM API is very slow to respond it could take some time and wherefore many waiting processes potentially. |
Hmm I only have an older version available.
Ok maybe it is possible to set a user-specific mutex/synchronized/semaphore in PHP? I did a short search and found so many completely different approaches (some only work on Linux, some are deprecated/removed, some are dependent on other libraries) that it overwhelmed me. |
I don't see why (Of course one has to be having Locking at SQL server level is most centralizes, as your data itself is there. There are of course many other ways if you insist on client-side locking. Most portable is There are other, more performant ways, like the use local IPC methods like semaphores, but that also assume running GNU/Linux (or some other POSIX machine) and have their own caveats). TL;DR: unless you plan to change the database, I'd stick with mysql innodb transactions + |
At the moment it is possible that the code is concurrently updating the same user in parallel in response to either multiple requests with the same user or by running a request and the cron update at the same time.
I think nothing bad happens from it beside unnecessary requests to the OSM API.
It could be prevented by usage of transactions over the whole process for each user and
SELECT FOR UPDATE
on thechangesets_walker_state
entry for the user.The text was updated successfully, but these errors were encountered: