I use MongoDB to store user data for a game I work on. There is an xp (experience) field that exists for every user in the game. I have my server retry requests to the database if it fails due to a network outage or if the database is down. If an $inc operation manages to execute on the database but doesn’t respond to the server (network outage), a duplicate $inc could happen due to the server retrying. Is this something I should worry about, and how would I avoid this case if I should?
$inc is not an idempotent operation, So if you don’t be cautious, you may end up incrementing something twice.
e.g. if you get “timeout”, you won’t know if the operation indeed finishes on server side or not.
Thanks, I will try to design something to prevent this case from happening.
This topic was automatically closed 5 days after the last reply. New replies are no longer allowed.