CosmosDB Inconsistent Read Behavior

Kenneth Miner 21 Reputation points
2020-08-25T23:29:52.907+00:00

Our team is evaluating CosmosDB and is seeing inconsistent read behavior when querying data through the PHP MongoDB client.

Identical queries for a single < 1kb document (in a collection with only that document) will often return NULL rather than the expected document.

Comparing the Cursors returned by the queries show identical server data (i.e. the host receiving the query).

Using the same MongoDB client to make a query multiple times appears to eventually resolve the issue, in that it eventually returns the expected document and subsequent duplicate queries no longer return null.

This issue is anecdotally most easy to reproduce on newly created Collections, but we haven't been able to identify any specific repro cases other than "keep doing it and it will occasionally break".

Are there any known issues related to this behavior?

Please let me know if I can provide additional details!

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

1 answer

Sort by: Most helpful
  1. Kenneth Miner 21 Reputation points
    2020-09-01T19:55:38.217+00:00

    Thanks for your response @Mike-Ubezzi-MSFT. I tried to respond to your comment but the site didn't seem to want to accept my input.

    We're using the 3.6 API for MongoDB via the standard PHP driver. (Note we're on PHP and not Python :) )

    $client = new MongoDB\Client(
    'mongodb://*******:10255/?ssl=true&replicaSet=globaldb&retrywrites=false'
    );
    $db = $client->selectDatabase("env-testing", ['typeMap' => ['root' => 'array', 'document' => 'array','array' => 'array']]);
    $collectionName = "1_bindings";
    $data = $db->$collectionName->findOne(["key" => "c1acce761bbf7d0810c5f5b71f3f20c2b75033eb"]);

    This morning I ran a test, querying for a single item in the 1_bindings collection 10 times with 10 separate connections. All 10 were successful.
    Then I deleted the 1_bindings collection, recreated it and added the same item. I ran the same test code 15 times and only got the document back 11/15 times. In the failure cases (2, 5, 11, 13), the server returned false as if the document did not exist with no other messages indicating an error.

    Is there a way I can enable/access detailed logging in CosmosDB to try to further track the failed attempts?