nerdexam
Microsoft

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.

Design and implement data distribution

Question

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 container2. The following is a sample of a document in container1: { "customerId": 1234, "firstName": "John", "lastName": "Smith", "policyYear": 2021 } The following is a sample of a document in container2: { "gpsId": 1234, "latitude": 38.8951, "longitude": -77.0364 } You need to configure conflict resolution to meet the following requirements: - For container1 you must resolve conflicts by using the highest value for policyYear. - For container2 you must resolve conflicts by accepting the distance closest to latitude: 40.730610 and longitude: -73.935242. - Administrative effort must be minimized to implement the solution. What should you configure for each container? To answer, drag the appropriate configurations to the correct containers. Each configuration may be used once, more than once, or not at all. You may need to drag the split bar between panes or scroll to view content. NOTE: Each correct selection is worth one point. Answer:

Exhibit

DP-420 question #40 exhibit

Answer Area

Drag items

Last Write Wins (default) modeMerge Procedures (custom) modeAn application that reads from the conflicts feed

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

#Cosmos DB#Conflict Resolution#Multi-region Writes#Stored Procedures

Community Discussion

No community discussion yet for this question.

Full DP-420 Practice