Azure Table Storage data Consistency
- by SeeR
Let say I have Table in Azure Table Storage
public class MyTable
{
public string PK {get; set;}
public string RowPK {get; set;}
public double Amount {get; set;}
}
And message in Azure Queue which says Add 10 to Amount.
Now let say one worker role
Takes this message from queue
Takes row from table
Amount += 10
Updates Row in Table
And Fails
After a while message is available in queue again. So next worker role:
Takes this message from queue
Takes row from table
Amount += 10
Updates Row in Table
Removes message from queue
Those actions results in Amount += 20 instead of Amount += 10.
How can I avoid such situations?