【问题标题】:Document DB SDK with ORDER BY caused ServiceUnvailableException带有 ORDER BY 的 Documentdb SDK 导致 ServiceUnavailableException
【发布时间】:2019-12-12 14:43:46
【问题描述】:

我正在使用 DocumentDB。给定索引策略:

messageType:字符串 - 精度 -1

deviceId:字符串 - 精度 -1

查询 1:

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

查询 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

执行代码:

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>();

查询 1 有效,但查询 2 抛出异常:

{
  "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.
}

不同的是“ORDER BY”命令。 有什么解决办法吗?

【问题讨论】:

  • partitionKey 是什么?
  • PartitionKey 是 deviceId。由于查询使用“EnableCrossPartitionKey”,我认为可能不需要。

标签: database indexing azure-cosmosdb azure-sdk-.net


【解决方案1】:

我在门户中测试了查询 2,它就像一个魅力。 因此,在应用程序中,我将 ConnectionPolicy 更改为:

网关 - HTTPS

现在应用程序正在运行。 此问题看起来与 Document DB SDK 有关,以确保我将继续测试并向 Github 存储库报告。

【讨论】:

  • 这种情况是由于网络限制,Direct-TCP不能工作。但是,让 CPU 100% 并抛出 ServiceUnAvailableException 是很奇怪的。
猜你喜欢
  • 2012-03-17
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2018-09-13
  • 2016-11-30
  • 2013-01-16
相关资源
最近更新 更多