1 database
has 2 servers
there are 2 users
server – 1
server – 2
user – 1
user – 2
user – 1, working with the server – 1
user – 2, working with the server – 2
user – 1 and user – 2 made simultaneous requests to their servers at the same time, and at the same time selected the same data from the database and saved this data each to its own variable on its server
user 1 did something and decided to save the data in the database, while user 2 still has the old data in the variable, and user 2 does not know that they have changed and decided to save his changes in the database too
It turns out that only changes from the user – 2 will remain in the database,
how to solve this problem?