DP-420 · Question #40
Drag and Drop Question You have an Azure Cosmos DB for NoSQL account that is configured for multi-region writes. The account contains a database that has two containers named container1 and…
The correct answer is Container1: Last Write Wins (default) mode; Container2: Merge Procedures (custom) mode. The correct conflict resolution modes are Last Write Wins for Container1 due to its ability to specify a numeric conflict resolution path like 'policyYear', and Merge Procedures for Container2 to implement custom spatial logic for distance calculation.
Question
Exhibit
Answer Area
Drag items
Correct arrangement
- Container1: Last Write Wins (default) mode
- Container2: Merge Procedures (custom) mode
Explanation
The correct conflict resolution modes are Last Write Wins for Container1 due to its ability to specify a numeric conflict resolution path like 'policyYear', and Merge Procedures for Container2 to implement custom spatial logic for distance calculation.
Approach. For Container1, the requirement is to resolve conflicts by using the highest value for 'policyYear'. Azure Cosmos DB's Last Write Wins (LWW) conflict resolution mode, while defaulting to the '_ts' (timestamp) property, allows you to configure a custom numeric property as the conflict resolution path. By setting 'policyYear' as the conflict resolution path, LWW can automatically select the document with the highest 'policyYear' value, directly meeting the requirement with minimal administrative effort as it's a built-in configuration option. Therefore, 'Last Write Wins (default) mode' is dragged to 'Container1'.
For Container2, the requirement is to resolve conflicts by accepting the document closest to a specific latitude and longitude. This involves complex spatial calculations that cannot be handled by a simple numeric comparison property like those available with Last Write Wins. Azure Cosmos DB's custom conflict resolution mode, 'Merge Procedures', allows you to implement a server-side JavaScript stored procedure. This stored procedure can contain the necessary logic to calculate distances between geographic coordinates and select the winning document, thus fulfilling the requirement. This method minimizes administrative effort compared to an external application handling the conflicts. Therefore, 'Merge Procedures (custom) mode' is dragged to 'Container2'.
Common mistakes.
- common_mistake. Using 'Merge Procedures (custom mode)' for Container1 would technically work, but it involves writing and maintaining a custom stored procedure for a task that Last Write Wins can handle with a simple configuration change (setting the conflict resolution path to 'policyYear'). This would violate the 'minimize administrative effort' requirement. Conversely, using 'Last Write Wins (default) mode' for Container2 would be incorrect because LWW cannot perform complex spatial calculations; it only compares a single numeric property. Finally, 'An application that reads from the conflicts feed' is generally a last resort for conflict resolution. While it provides the ultimate flexibility, it requires developing, deploying, and maintaining an external application, significantly increasing administrative effort compared to server-side options like custom stored procedures, especially if the resolution logic can be automated within Cosmos DB.
Concept tested. Azure Cosmos DB conflict resolution strategies for multi-region writes, including Last Write Wins (LWW) with custom conflict resolution paths, and custom conflict resolution logic using merge procedures (stored procedures). It also tests the understanding of administrative effort associated with each method.
Reference. null
Topics
Community Discussion
No community discussion yet for this question.
