CGI-AMS Interview Question
Java DevelopersCountry: Canada
Interview Type: Phone Interview
One way is to enforce a read before a write to the web page. That ensures that every write is on the most updated data. But even that is not sufficient. THe 'RMW has to be atomic in some manner. For example, when a read is done for a subsequent write, a locking mechanism can be used with a timeout. The locking mechanism should use some identification that the subsequent write will provide that will allow it to go through.
A plain read from the second admin will be let thru but a RMW from second admin will either return an error code (try again) or block till the first write is completed.
Can we use lastUpdatedTimestamp column in the product table and when we update it should same otherwise an exception is thrown with appropriate message and the page will be refreshed by calling the getproduct service.Admin2 has to reenter the data if he wants to update on top of the last update.
Solution 1
- Sv December 03, 2015.
When admin2 is trying to update the 'description', a validation can be done against the admin2 page 'description ' with the updated data from the database.if it doesn't match
alert the user saying content changed and reload the page.
solution 2
When admin1 has changed the page content send an alert message to the admin2 session asking to reload the page.