shah-anurag / tiny-url

Get shortUrls and live a simpler life
MIT License
2 stars 0 forks source link

Failure handling #1

Open shah-anurag opened 3 years ago

shah-anurag commented 3 years ago

When Application Server fails to register a long URL, KeyDb still registers the shortUrlId in the UsedKey collection. Fix it

shah-anurag commented 3 years ago

Upon thinking more on this, I feel it is the right behavior. We can have KGS remove the key from RemainingKeys collection and return that to appServer which can write the keys to UsedKeys collection after it was successfully able to store in the URL collection but that would affect the logic of KeyDb as it can potentially generate the same key and reenter it in the RemainingKeys collection meanwhile. With present architecture in worst case scenario we would loose some keys as they would be wrongly marked as Used but that's ok as we have a lot of keys

shah-anurag commented 3 years ago

This issue occurs even when already registered longURL is used for registering again. This is a red flag as this can get exploited easily which can potentially cause keydb to use up all the shortUrlIds without even actually registering a single longURL