Azure Table Storage data Consistency

Posted by SeeR on Stack Overflow See other posts from Stack Overflow or by SeeR
Published on 2009-11-19T14:00:16Z Indexed on 2010/04/09 17:43 UTC
Read the original article Hit count: 726

Filed under:
|

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

  1. Takes this message from queue
  2. Takes row from table
  3. Amount += 10
  4. Updates Row in Table
  5. And Fails

After a while message is available in queue again. So next worker role:

  1. Takes this message from queue
  2. Takes row from table
  3. Amount += 10
  4. Updates Row in Table
  5. Removes message from queue

Those actions results in Amount += 20 instead of Amount += 10.

How can I avoid such situations?

© Stack Overflow or respective owner

Related posts about Azure

Related posts about windows-azure