Hi ,
Thanks for reaching out to Microsoft Q&A.
It sounds like you are running into cosmos db's behavior in multi-write regions, but there are a few key points to consider:
Why are you getting a 409 conflict but not seeing conflicts stored?
- Default "last writer wins" mode
- In a multi-region write-enabled cosmos db setup, the default conflict resolution strategy is last writer wins (LWW). This means that when a conflict occurs, the system automatically resolves it based on the defined conflict resolution policy.
- If you haven't explicitly set a custom conflict resolution strategy (custom stored procedure based resolution), conflicts will be automatically resolved without being recorded in the conflict feed.
- The conflict feed is empty
- The conflict feed is only populated if you set custom conflict resolution using stored procedures.
- If your container is using the default lww strategy, conflicts will never appear in the conflict feed because cosmos db resolves them automatically.
- 409 conflict vs. Conflict feed
- A 409 conflict error occurs at the sdk level when you try to insert a document with an already existing id.
- However, this is not the same as a conflict that is eligible for conflict resolution. If two regions try to insert different versions of the same document at the same time, and there’s a conflict, cosmos db handles it based on your conflict resolution policy.
- A 409 conflict error occurs at the sdk level when you try to insert a document with an already existing id.
- The conflict feed is only populated if you set custom conflict resolution using stored procedures.
- If you're getting a 409 Conflict, it's due to an attempt to insert an existing ID, which is an SDK level constraint.
- Cosmos DB doesn't store conflicts unless conflict resolution is explicitly set to "Custom".
- If you want stored procedures to resolve conflicts, you must configure a custom conflict resolution policy and query the conflict feed.
Please feel free to click the 'Upvote' (Thumbs-up) button and 'Accept as Answer'. This helps the community by allowing others with similar queries to easily find the solution.