-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Closed
Description
This is a COPY of Issue 765: Concurency issues with yourls-api.php, filed on Google Code before the project was moved on Github.
- Submitted on 2011-04-17T02:08:21.000Z by raccettu
- Status: Fixed
Please review the original issue and especially its comments. Comments here on closed issues will be ignored. Thanks.
Original description
So I've got a script that hits yourls API to get a short url. The script has basic caching to help prevent multiple API hits, however until the first one resolves, it will keep firing off API requests since it has nothing to serve until the cache is primed.
The result here is that if the yourls API is hit quickly with the same URL, you can have duplicate entries. In my case a dozen for the same exact URL. The correct behavior is 1 short url per URL. The rest should return the original URL. This works correctly when it doesn't happen so quickly.
The reason is that the write operation isn't instant, so if multiple requests are fired before it's written, the duplicate 'exists' check is still false.
I think a temporary table, lock file or some other faster mechanism is needed to help prevent this concurrency issue. Otherwise anyone with API access can make a real mess out of the database. I accidentally ran across this and ended up making about 1k bogus short url's. Thankfully I could figure out what they were and delete them pretty easily and restore my next_id.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels