azure-cosmosdb - 使用 Cosmos DB 的 Hangfire:响应状态代码不表示成功:NotFound (404);子状态:0;活动 ID
问题描述
我有使用 Cosmos DB 作为数据库的 Hangfire。当我选择重试选项卡时,我收到错误:
An unhandled exception occurred while processing the request.
AggregateException: One or more errors occurred. (Response status code does not indicate success: NotFound (404); Substatus: 0; ActivityId: 68d632fc-8c5a-4624-80a5-7e9bc0d252f0; Reason: ({
"Errors": [
"Resource Not Found. Learn more: https://aka.ms/cosmosdb-tsg-not-found"
]
});)
System.Threading.Tasks.Task.Wait(int millisecondsTimeout, CancellationToken cancellationToken)
CosmosException: Response status code does not indicate success: NotFound (404); Substatus: 0; ActivityId: 68d632fc-8c5a-4624-80a5-7e9bc0d252f0; Reason: ({
"Errors": [
"Resource Not Found. Learn more: https://aka.ms/cosmosdb-tsg-not-found"
]
});
Microsoft.Azure.Cosmos.ResponseMessage.EnsureSuccessStatusCode()
当我尝试在 Cosmos DB 上进行 select 语句以获取具有以下内容的项目时key='retries'
:
SELECT * FROM c where c.key = 'retries' and c.value = 'b7ad3971-8647-4a29-a2a7-412e2da41527'
我在 Cosmos DB 中遇到错误:
Failed to query item for container hangfire:
Gateway Failed to Retrieve Query Plan: Message: {"errors":[{"severity":"Error","location":{"start":46,"end":51},"code":"SC1001","message":"Syntax error, incorrect syntax near 'value'."}]}
ActivityId: 4bc1d85a-4ea6-47c2-95d0-81bdde78f389, Microsoft.Azure.Documents.Common/2.11.0, Microsoft.Azure.Documents.Common/2.11.0
当我这样选择时:
SELECT * FROM c where c.key = 'retries'
我可以看到没有错误的结果。添加AND c.value=...
到 where 子句时发生错误。我无法在 上打开重试选项卡Hangfire dashboard
。Cosmos 中的 Json 看起来像:
{
"key": "retries",
"value": "b7ad3971-8647-4a29-a2a7-412e2da41527",
"score": 0,
"created_on": 1611580578,
"type": 7,
"id": "b04c5c23-d324-45e1-acce-cdd2379c4073",
"_rid": "QO5WANzKkljY-gEAAAAAAA==",
"_self": "dbs/QO5WAA==/colls/QO5WANzKklg=/docs/QO5WANzKkljY-gEAAAAAAA==/",
"_etag": "\"2d01ed73-0000-0100-0000-600ec4a30000\"",
"_attachments": "attachments/",
"_ts": 1611580579
},
解决方案
您收到此错误的原因是因为value
是关键字。请尝试以下查询,它应该可以工作:
SELECT * FROM c where c.key = 'retries' and c["value"] = 'b7ad3971-8647-4a29-a2a7-412e2da41527'
推荐阅读
- liquibase - 运行应用程序时,回滚选项卡在 liquibase 中不起作用,控制台输出中没有错误
- javascript - 笑话:如何在同一个文件上模拟一个 promise 来解决和拒绝选项?
- jquery - 计算已检查属性的最短方法
- javascript - 我应该在 React 中硬编码数据还是使用道具?
- c++ - 标准是否保证 uint8_t、int8_t 和 char 都是唯一类型?
- opengl - 将 spirv 与 OpenGL 一起使用,gl_VertexIndex 始终为 0
- unit-testing - Junit java.lang.IllegalArgumentException:无法解析值“$ {cors.origin.value}”中的占位符“cors.origin.value”
- python - 急切执行函数的输入不能是 Keras 符号张量
- django - 无法显示登录用户的完整详细信息?
- python - Python:扁平化字典列表的最佳方法是什么