5

I'm using DocumentDB. Given index policy:

messageType: string - precision -1

deviceId: string - precision -1

Query 1:

SELECT * FROM c WHERE c._ts >= 1563721200 AND c._ts < 1563807600 AND c.messageType = 'attack' AND c.deviceId >= 'A' AND c.deviceId < 'Z'

Query 2:

SELECT * FROM c WHERE c._ts >= 1563721200 AND c._ts < 1563807600 AND c.messageType = 'attack' AND c.deviceId >= 'A' AND c.deviceId < 'Z' ORDER BY c._ts DESC

Executing code:

var query = dbClientSource.CreateDocumentQuery<Document(UriFactory.CreateDocumentCollectionUri(db, collection),
             sql,
             new FeedOptions { MaxItemCount = 100, EnableCrossPartitionQuery = true })
             .AsDocumentQuery();
while (query.HasMoreResults)
       var result = await query.ExecuteNextAsync<Telemetry>();

Query 1 worked, however query 2 throw exception:

{
  "code": "ServiceUnavailable",
  "message": "The request failed because the client was unable to establish connections to 1 endpoints across 1 regions. The client CPU was overloaded during the attempted request.
}

The different thing is "ORDER BY" command. Is there any solutions?

duy
  • 579
  • 5
  • 16

1 Answers1

2

I tested the query 2 in portal and it works like a charm. So, in the application I changed ConnectionPolicy to:

Gateway - Https

Now the application is working. This issue look like relates to Document DB SDK, to make sure I will continue to test and report to Github repository.

duy
  • 579
  • 5
  • 16
  • This case happen due to network retriction, Direct-TCP cannot work. However, it is very strange to make CPU 100% and throw ServiceUnAvailableException. – duy Aug 16 '19 at 04:13