Does CosmosDB for MongoDB honour the ordered writes parameter for inserts during bulk write operations?

Kiruphasankaran Nataraj 0 Reputation points
2023-07-31T07:37:43.27+00:00

I'm using the MongoDB Java Driver version 4.8.2 to insert around 10000 documents with upsert enabled using bulk write operations. I've enabled ordered writes and disabled the Server Side Retry feature. My MongoDB server version is 4.2.

However, I'm experiencing issues where the documents are not inserted in order and the operation throws an exception due to Server Side Retry being disabled. I'm wondering if CosmosDB honors the ordered writes parameter when performing inserts during bulk write operations.

Additionally, the error index returned from the bulk write exception doesn't seem to correspond to the first non-written document in the list. Is there a recommended way to handle errors due to throttling when Server Side Retry is enabled?

Azure Cosmos DB
Azure Cosmos DB
An Azure NoSQL database service for app development.
1,902 questions
{count} votes

2 answers

Sort by: Most helpful
  1. Oury Ba-MSFT 20,911 Reputation points Microsoft Employee Moderator
    2023-08-02T04:31:05.9566667+00:00

    @Kiruphasankaran Nataraj Thank you for getting back and for sharing the error message.

    Azure Cosmos DB for MongoDB operations may fail with rate-limiting (16500/429) errors if they exceed a collection's throughput limit (RUs).

    You should not do ordered writes, it reduces performance: Optimize write performance in the Azure Cosmos DB for MongoDB | Microsoft Learn

    Server side retry should be enabled to prevent rate limiting errors. 

    Please turn off retryable writes- I don't think it's needed since network errors don't appear to be an issue. With this feature, you can't do bulk unordered writes, which will prevent you from implementing the recommendation in the first point. 4.2 server version supported features and syntax in Azure Cosmos DB for MongoDB | Microsoft Learn

    Hope that clarifies your ask.

    Please don't forget to mark as accept answer if the reply was helpful.

    Regards,

    Oury


  2. Nguyen Le 0 Reputation points
    2024-04-10T13:04:11.2166667+00:00

    I'm using the MongoDB C# Driver version 2.24.0 to insert around 7.7 million documents with IsOrder set to false using bulk write operations.
    The request rate unit is manual set are 10000 RU
    I've enabled the Server Side Retry feature to prevent rate limiting errors. My Azure Cosmos DB for MongoDB server version is 4.2.
    I get poor performance around 15 hours to finish insert.
    Can anybody help me to explain what happen?


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.