Hello! ![]()
I guess this is a known problem in informatic engineering, but I have not enough academic formation, so It would be great if you could give me some answers to this problem.
I have a MySQL database storing users profiles.
From server-side, there is a module which updates users profiles automatically (daily earnings, profit loss, etc.) in the Database, and it does it with top priority.
From client-side, online players can also modify their profiles while playing.
Now comes the problem. Let me explain:
When an user performs an action (variable updates), the variables related with that action are compared with the real DB variables. If they arenât the same, then a variables update is sent to the client, letting him decide what to do with new variables, and nothing else. Otherwise, the variable update is performed and the Database modifies the desired values. But, if the server-side module modifies that set of variables just after the variable comparison and just before the variable update, then the final result is may not be the expected.
For example, if my character has 100$ and I spend it all, and between the Read-Write process the server side module automatically deducts another 100$ (because they have not been deducted yet), then I will have -100$ at the end of the process.
Anyone could indicate me a way to aviod this? ![]()
PD: Iâve thought about making the Read-Write process in the same SQL query, beacuse (I guess) that different queries are not processed at the same time, arenât they? ![]()