Learn how to correctly implement a custom conflict resolution policy for multi-region writes in Azure Cosmos DB using the SDK. Understand the key components and best practices for handling conflicts.
Table of Contents
Question
You have a database in an Azure Cosmos DB for NoSQL account that is configured for multi-region writes.
You need to use the Azure Cosmos DB SDK to implement the conflict resolution policy for a container. The solution must ensure that any conflicts are sent to the conflicts feed.
Solution: You set ConflictResolutionMode to Custom. You set ResolutionProcedure to a custom stored procedure. You configure the custom stored procedure to use the isTombstone parameter to resolve conflicts.
Does this meet the goal?
A. Yes
B. No
Answer
B. No
Explanation
This solution does not meet the goal of ensuring that any conflicts are sent to the conflicts feed. Let’s break down why:
- ConflictResolutionMode: Setting this to “Custom” is correct for implementing a custom conflict resolution policy.
- ResolutionProcedure: Setting this to a custom stored procedure is also a valid approach for custom conflict resolution.
- isTombstone parameter: This is where the solution falls short. The isTombstone parameter is not directly related to sending conflicts to the conflicts feed.
To ensure that conflicts are sent to the conflicts feed, you need to set the ConflictResolutionMode to “LastWriterWins” and set the ConflictResolutionPath to “/_ts” (timestamp path). This configuration tells Azure Cosmos DB to use the last writer wins policy based on the timestamp, but more importantly, it allows conflicts to be written to the conflicts feed for later processing.
The correct steps to meet the goal would be:
- Set ConflictResolutionMode to “LastWriterWins”
- Set ConflictResolutionPath to “/_ts”
- Enable the conflicts feed for the container
By configuring the container this way, any conflicts that occur during multi-region writes will be automatically sent to the conflicts feed. This allows you to review and handle conflicts programmatically at a later time, giving you more control over the conflict resolution process.
It’s important to note that when using the custom conflict resolution mode with a stored procedure, conflicts are typically resolved immediately and are not written to the conflicts feed. This is why the proposed solution does not meet the specific requirement of ensuring conflicts are sent to the conflicts feed.
Microsoft DP-420 certification exam practice question and answer (Q&A) dump with detail explanation and reference available free, helpful to pass the Microsoft DP-420 exam and earn Microsoft DP-420 certification.