Hi Experts,
i've found a race condition while performing an update statement on my oData service. To achieve concurrency control i'm using eTags which is already working fine for most situations. But there is a sequence that i can not handle with eTags, let me describe it in the following table. The left column contains the actions for User 1, the right one those for User 2. To show the chronological order the steps are ordered from top to bottom, so that the action in row 1 ist executed before row 2 and so on. The entries highlighted in bold red are the actual actions performed by users, the other entries serve for better understanding.
When performing an Update-Statement in SAPUI5 the framework is automatically calling the "GetEntity"-Method to compute the necessary eTag and comparing it with the timestamp used by the Application (simplified). Only when both eTags are matching the Update-Statement will be executed.
Nr | User 1 Action | User 2 Action |
---|---|---|
1 | Calling GetEntity and comparing eTag --> OK | |
2 | Calling GetEntity and comparing eTag --> OK | |
3 | At this point both users are able to update the entity | At this Point both users are able to update the entity |
4 | Performing Update | |
5 | Now User 1 is working on the updated dataset | Now User 2 is working on an outdated dataset |
6 | Performing Update | |
7 | User 2 has overwritten the data of User 1 | |
8 | User 1 does not know about the changes of User 2 | User 2 has never seen the changes of User 1 |
As you can see both users could update the dataset without noticing the changes of the other one. I can also provoke this behaviour using the Debugger, so this is a "real-life" problem. The only solution i found is to raise an exception in the Update-Routine, but therefore i have to check the timestamp on my own - a feature that i thought eTags could handle for me.
Finally my question: is there another approach to handle this race condition?
Best regards
Lukas