21.06.04

Prevent Concurrent Updates through Webinterfaces

When you provide a set of special administrators a webinterface to update a set of data, how do you insure, that the data gets not updated concurrently?
In this case concurrently means, that two persons retrieve the data into a form field and both do updates based on this data. Now in a naive developed webapp, the data of the first save will be lost, since the second one will overwrite it.
To prevent this you can insert a new date field into your database and store there the last value of an update. This date data is stored in a hidden form field and whenever an update is called you check if the submitted date is the one in the DB. If true the data in the form field was up-to-date and an update on the DB is save. Otherwise you have to reject the update and send the new data to the client to enable him to update his part based on the new data.
This is a trick I just learned from Toni at Jato Consulting.

Posted by Karsten at 21.06.04 00:19 | TrackBack
Comments
Post a comment









Remember personal info?