I've read the article.
The article describes the next solution to situations when many users can write to the same DB.
You as a user need to:
- Retrieve the row and the last modified
dateTime
of the row. - Make the calculations you want, but don't write anything to the DB yet.
- After the calculations, just before you want to write the result to the DB, retrieve the last modified
dateTime
of the same row again. - Compare the date time of #1 to the
dateTime
of #2. If they equal - everything is ok, commit, and write the current time as the last modified date time of the row. else - other user was here - Rollback.
This process seems logical, BUT I see the next hole in it:
In #3 the user retrieves the last modified dateTime
of the row, but what if between the reading of this dateTime
(in #3), and the time of writing in #4, an other user enters, writes its data and get out? The first user can never know about it, and it will override the second user's data.
Isn't it possible?