Reputation: 163
While working with Azure Table Storage, I'm getting concurrency issues with multiple threads. Each thread is trying to update the same record (Partition key + Row key). In that case, my expectation is that if it is stale data, the library will automatically check the etag
and throw an exception 412 Pre-Condition Failed. But, in my situation, it is always updating with last call.
It's worth noting that if I use TableEntityOperation.Replace(entity)
, it does throw the 412 exception. It seems like TableEntityOperation.InsertorMerge(entity)
doesn't check for concurrency.
Upvotes: 0
Views: 765
Reputation: 136336
The reason you are seeing this behavior is because TableEntityOperation.InsertorMerge(entity)
method, which is a wrapper over Insert Or Merge Entity
REST API operation does not support optimistic concurrency. Only Merge Entity
and Update Entity
support optimistic concurrency.
From the documentation
(emphasis mine):
The Insert Or Merge Entity operation uses the MERGE verb and must be called using the 2011-08-18 version or newer. In addition, it does not use the If-Match header. These attributes distinguish this operation from the Update Entity operation, though the request body is the same for both operations.
Upvotes: 3