Brief Intro of what happens in Lost Updates?
A simple example which will make you understand Lost Update.
For an example:
Session 1: User A reads record 1
Session 2: User B reads record 1
Session 1: User A updates record 1
Session 2: User B updated record 1
User B have not seen the record updated by User A and updated the existing record resulting in Lost Updates.
How can we tackle it programmatically?
There are the other solutions too such as generating a random number and assigning the number to a record.
Let’s see how we can handle these in ODATA
It’s too cumbersome to do the above things and put into the service with Hana. Here where the etag functionality of ODATA services comes into picture. We need to take care of few things and we are ready to save database from lost updates.
These mechanism can be applied both on the tables and views. For views you have to specify the key.
Here is an example of simple service that does the task for us:
Now when you do get the data from the service you will always get the etag in the metadata. As show in screen shot below:
Look at the screen shot we get the etag in request from server.
Now the ETags comes with two different options weak and strong tags.
We will go here with weak tag. Screen shot from using the postman:
If-match header have two options one is the value etag value and the other can be *. If value is provided it will validate against the token and for * it will not validate it.
If you update the record twice it will give you error as “412 precondition failed” because the etag token is changed.
Can find more information about the etags at:
OData ETag Support - SAP HANA Developer Guide for SAP HANA Studio - SAP Library
Hope this will help. :smile:
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
36 | |
7 | |
5 | |
5 | |
5 | |
4 | |
4 | |
4 | |
3 | |
3 |