如果我有一个具有会话一致性的DocumentDB数据库,那么使用etags对同一文档的并发写入有什么保证?例如,A和B在不同的会话中运行:
-
阅读:A - etag:1
-
阅读:B - etag:1
-
写:A - etag:1(匹配,etag = 2)
-
写:B - etag:1?
假设写入:B失败,因为etag是2,但是我没有找到任何关于DocumentDB从服务器上读取etag值的保证的明确文档,如 could it read from a secondary replica where the etag is still 1, and let Write:B still go through ?
这个问题Session Guarantee on DocumentDB在评论中讨论了这个问题,但似乎没有得出结论 .
Web文档
来自FAQ https://docs.microsoft.com/en-us/azure/documentdb/documentdb-faq
从示例源(暗示,但未说明,这在所有一致性级别都适用?)https://github.com/Azure/azure-documentdb-dotnet/blob/master/samples/code-samples/DocumentManagement/Program.cs:
1 回答
DocumentDB团队成员在这里 . 确认Larry的答复,即对所有一致性级别强制执行使用ETag的条件写入 . 写请求必须包括ETag(REST中的If-Match标头,.NET中的RequestOptions.AccessCondition) .