Closed (outdated)
Project:
ShURLy
Version:
7.x-1.x-dev
Component:
Code
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Issue tags:
Reporter:
Created:
21 Sep 2015 at 06:29 UTC
Updated:
8 Sep 2025 at 08:22 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #2
kilowattz commentedComment #3
jibus commentedWell, i am wondering if it's not around here :
In shurly.module
function shurly_shorten()
In shurly_get_latest_short()
It checks if the long url is in the database. But since the $account->uid can be different...
Also in the request, there is an extra semicolon.
Comment #4
dropchew commentedSounds like a race condition, created timestamps are the same
Comment #5
spaghettibolognese commentedThis patch adds locking support to shurly_shorten(). Fixed our problems.
Comment #6
jibus commentedComment #7
kilowattz commentedWe tested the patch in #5 with our dev environment and nothing breaks. All features including the api still work. We are having a hard time replicating the issue intentionally. We target to use this patch in our prod environment after a few more tests.
Comment #8
robloachAnother solution may to be set an INDEX on the Shurt URL column in the table. then it will error out when trying to create a duplicate.
Comment #9
jmarkel commentedJust my 2 cents but @RobLoach's suggestion about setting an INDEX on the 'source' column might be less problematic and more performant (at the cost of some additional space in the database). Locks can be problematic in general and lock contention can slow things down...
Comment #10
jibus commentedCan you make a patch for this ?
Comment #11
jmarkel commentedHmmm interesting - 'source' is already defined as an index. Makes me wonder how this didn't throw an error. Or, maybe, it did but error messages were hidden?
Comment #12
spaghettibolognese commentedWe can make the 'source' field unique, but that wont solve the race problem, it would just cause an sql error. I dont think that is expected behaviour, hence the locking.
Comment #13
jmarkel commentedNo, it won't 'solve' the race condition, but it will prevent duplicates, and the code could catch the SQL error and regenerate the short url. As I said, the locking will work - but locks have problems of their own (lost locks causing things to block, contention delays ...).
Comment #14
norman.lol