![]() In order to improve this I have written an article on generating true random numbers which you can find below and can help you remediate this problem. The disadvantage of the above method however is that you cannot reliably always get a unique number unless you are using a true source of randomness, especially if you are having multiple Lamba’s doing the update and timing could be an issue. ![]() The advantage of this method is that you will be guaranteed uniqueness and you will be able to do this in only one query. ![]() The UUID number can be composed by any random pseudo or not generated number and then replace the ID. Instead of using an identifier you can use a unique UUID number. ![]() This method is fairly simple but it would require you to do some extra work. A Better Workaround – Use a Different Unique ID If the above considerations are taking into place then you can abstract the logic and have it happen automatically. User 2wants to do the same thing, while the first fetch is running the second one is also running (insert hasn’t completed yet) so User 2 gets the identifier as 3 too. User 1 wants to insert a record in your database, so they fetch the last identifier let’s assume this is number 3. The last pointer seems rare but consider the following scenario:
0 Comments
Leave a Reply. |