If I have a DocumentDB database with Session consistency, what guarantees are there for concurrent writes of the same document using etags? For example, with A and B operating in different sessions:
The assumption is that Write:B fails since etag is 2, but I haven't found any explicit documentation on what guarantee there is for where DocumentDB reads the etag value from on the server, as in, could it read from a secondary replica where the etag is still 1, and let Write:B still go through?
This question Session Guarantee on DocumentDB discusses the issue in the comments, but does not seem to come to a conclusion.
From the FAQ https://learn.microsoft.com/en-us/azure/documentdb/documentdb-faq
From the example source (implies, but does not state, that this holds true at all consistency levels?) https://github.com/Azure/azure-documentdb-dotnet/blob/master/samples/code-samples/DocumentManagement/Program.cs:
DocumentDB team member here. Confirming Larry's reply that conditional writes with ETags will be enforced for all consistency levels. The write request must include the ETag (If-Match header in REST, RequestOptions.AccessCondition in .NET).
EDIT on 7/29/2019 with accounts configured for multi-region writes, there are no guarantees for ETag with multi-region writers, and you have to resolve concurrent writes via conflict resolution procedures. ETag validation still applies for single-region write accounts, as before.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With