Question

I'm new in Azure but i understand problems of it's parrallel execution model. I have a problem with operation synchronization in my web instance process. I have 2 instances for example (A and B). I have Table storage which have SomeData with some columns, but two columns (A,B) in row must be UNIQUE. *So, when user inserts SomeData i check if SomeData with columns A,B NOT Exists in my Table and inserts this data. But two users in parallel can add SomeData with identical columns A,B. How to eliminate logical duplicates in this case. I think about blob leases but maybe it exists some more convenient ways in this situation? I wanna execute some code (if not exists... do... Or if exists... do...) in my instances in consequent way.

Was it helpful?

Solution

Assuming instance A and B are entering inserting same data (same PartitionKey/RowKey), then only one of the instance will be able to successfully enter the data. Other instance will get a 409 - Conflict error. Can you not build your logic around that? In case an entity insert fails, you check for the error code and if the error code is conflict, then do something else.

I don't think blob lease would be helpful in this case. They are more suitable in scenario when you want only one instance to perform the insert.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top