我正在尝试使用 java 版本 4.52.0 同步代码的 cosmos-db sdk 从容器中读取项目。很多时候我遇到了 CosmosException,但这些异常中没有详细信息来表明实际出了什么问题。
下面给出了 CosmosException 的片段:
{
"innerErrorMessage": null,
"cosmosDiagnostics": {
"userAgent": "azsdk-java-cosmos/4.52.0 Linux/5.15.0-1051-azure JRE/21.0.1",
"activityId": "4f02cde3-c9c9-4c09-af6b-258f4d82db5d",
"requestLatencyInMs": 0,
"requestStartTimeUTC": "2023-12-15T18:23:24.381516148Z",
"requestEndTimeUTC": "2023-12-15T18:23:24.381762054Z",
"responseStatisticsList": [],
"supplementalResponseStatisticsList": [],
"addressResolutionStatistics": {},
"regionsContacted": [
"japan east"
],
"retryContext": {
"statusAndSubStatusCodes": null,
"retryLatency": 0,
"retryCount": 0
},
"metadataDiagnosticsContext": {
"metadataDiagnosticList": null
},
"serializationDiagnosticsContext": {
"serializationDiagnosticsList": null
},
"gatewayStatisticsList": [
{
"sessionToken": null,
"operationType": "Read",
"resourceType": "Document",
"statusCode": 0,
"subStatusCode": 0,
"requestCharge": 0,
"requestTimeline": [
{
"eventName": "connectionAcquired",
"startTimeUTC": "2023-12-15T18:23:24.381635051Z",
"durationInMilliSecs": 0.122203
},
{
"eventName": "connectionConfigured",
"startTimeUTC": null,
"durationInMilliSecs": 0
},
{
"eventName": "requestSent",
"startTimeUTC": null,
"durationInMilliSecs": 0
},
{
"eventName": "transitTime",
"startTimeUTC": null,
"durationInMilliSecs": 0
},
{
"eventName": "received",
"startTimeUTC": null,
"durationInMilliSecs": 0
}
],
"partitionKeyRangeId": null,
"responsePayloadSizeInBytes": 0,
"exceptionResponseHeaders": "{}"
}
],
"samplingRateSnapshot": 1,
"systemInformation": {
"usedMemory": "20807154 KB",
"availableMemory": "10650126 KB",
"systemCpuLoad": "(2023-12-15T18:22:55.851238339Z 40.2%), (2023-12-15T18:23:00.851247379Z 37.0%), (2023-12-15T18:23:05.851238334Z 35.5%), (2023-12-15T18:23:10.851252759Z 38.7%), (2023-12-15T18:23:15.851245468Z 42.3%), (2023-12-15T18:23:20.851240443Z 45.6%)",
"availableProcessors": 31
},
"clientCfgs": {
"id": 2,
"machineId": "vmId_17b8a761-9046-429e-8c32-42505a66b26c",
"connectionMode": "GATEWAY",
"numberOfClients": 2,
"excrgns": "[]",
"clientEndpoints": {
"https://redacted.documents.azure.com:443/": 2
},
"connCfg": {
"rntbd": null,
"gw": "(cps:10, nrto:PT1M, icto:PT5M, p:false)",
"other": "(ed: true, cs: false, rv: true)"
},
"consistencyCfg": "(consistency: Eventual, mm: true, prgns: [japaneast])",
"proactiveInit": "",
"e2ePolicyCfg": ""
}
}
}
提供的 JSON 代码段是使用 Java SDK 时来自 Azure Cosmos DB 的 CosmosException 诊断消息。虽然 statusCode 为 0 对于基于 HTTP 的响应来说并不常见(您通常期望 HTTP 状态代码,例如 404 表示“未找到”,403 表示“禁止”等),但它可能表示 SDK 或连接存在问题,而不是标准 HTTP 响应.
-确保此版本是最新版本或考虑更新到最新的 SDK 版本,以便从任何错误修复或改进中受益。