我在 AWS lambda 上有一个托管 MS Teams 机器人的无服务器后端。此机器人的状态存储在 CosmosDB 中。当我多次触发我的机器人时,我现在遇到了问题。我已经在 GitHub 上开过一张票,但不确定这是否应该被视为一个错误,或者更多是我可以修复的问题。该问题可以在这里找到:https ://github.com/microsoft/botbuilder-python/issues/1909
语境
当我连续多次触发我的机器人时,将激活多个 lambda 函数。然后这些函数将尝试并行处理这些消息。问题是他们都尝试更新 CosmosDb 中的机器人状态,这会导致 412 Precondition failed 错误。
我发现了这个问题:https ://github.com/microsoft/botframework-sdk/issues/3383简要介绍了它,但在 python 中没有。这是一个错误,或者如果不是,如何解决?从这个问题(见链接),我知道设置e_tag
为*
可以解决这个问题,但我无法弄清楚如何使用机器人构建器框架来完成。
是否不可能在无服务器后端有效地运行团队机器人?
错误信息:(抱歉格式错误)
{
"code": "PreconditionFailed",
"message": "Operation cannot be performed because one of the specified precondition is not met.,
RequestStartTime: 2022-01-30T20:06:38.3979751Z, RequestEndTime: 2022-01-30T20:06:38.3979751Z, Number of regions attempted:1
{"systemHistory":
[{
"dateUtc":"2022-01-30T20:05:43.2079379Z",
"cpu":6.250,
"memory":476859124.000,
"threadInfo":{
"isThreadStarving":"False",
"threadWaitIntervalInMs":0.0108,
"availableThreads":32764,
"minThreads":52,
"maxThreads":32767
}
},
{
"dateUtc":"2022-01-30T20:05:53.2179598Z",
"cpu":4.727,
"memory":476641220.000,
"threadInfo":{"isThreadStarving":"False",
"threadWaitIntervalInMs":0.0202,
"availableThreads":32763,
"minThreads":52,
"maxThreads":32767}},
{"dateUtc":"2022-01-30T20:06:03.2280107Z",
"cpu":3.988,
"memory":475937928.000,
"threadInfo":{"isThreadStarving":"False",
"threadWaitIntervalInMs":0.009,
"availableThreads":32763,
"minThreads":52,
"maxThreads":32767}},
{"dateUtc":"2022-01-30T20:06:13.2379856Z",
"cpu":3.700,
"memory":476703156.000,
"threadInfo":{"isThreadStarving":"False",
"threadWaitIntervalInMs":0.014,
"availableThreads":32765,
"minThreads":52,
"maxThreads":32767}},
{"dateUtc":"2022-01-30T20:06:23.2479144Z",
"cpu":3.914,
"memory":475827548.000,
"threadInfo":{"isThreadStarving":"False",
"threadWaitIntervalInMs":0.0186,
"availableThreads":32764,
"minThreads":52,
"maxThreads":32767}},
{"dateUtc":"2022-01-30T20:06:33.5679731Z",
"cpu":8.453,
"memory":476240572.000,
"threadInfo":{"isThreadStarving":"False",
"threadWaitIntervalInMs":0.0173,
"availableThreads":32757,
"minThreads":52,
"maxThreads":32767}}]}
RequestStart: 2022-01-30T20:06:38.3979751Z; ResponseTime: 2022-01-30T20:06:38.3979751Z; StoreResult: StorePhysicalAddress: rntbd://cdb-ms-prod-westeurope1-fd3.documents.azure.com:14063/apps/cecb85d1-f589-4032-ae16-245510f69d75/services/44a960dd-6df5-4912-b28f-882362c13880/partitions/b8c381bf-e212-42d3-ad45-1123a468435b/replicas/132806831075762246p/,
LSN: 444,
GlobalCommittedLsn: 444,
PartitionKeyRangeId: 0,
IsValid: True,
StatusCode: 412,
SubStatusCode: 0,
RequestCharge: 1.67,
ItemLSN: -1,
SessionToken: -1#444,
UsingLocalLSN: False,
TransportException: null,
BELatencyMs: 0.646,
ActivityId: 8091611d-5cec-4e17-a371-0c9490c5e51c,
RetryAfterInMs: ,
TransportRequestTimeline: {"requestTimeline":[{"event": "Created",
"startTimeUtc": "2022-01-30T20:06:38.3979751Z",
"durationInMs": 0.0085},
{"event": "ChannelAcquisitionStarted",
"startTimeUtc": "2022-01-30T20:06:38.3979836Z",
"durationInMs": 0.0027},
{"event": "Pipelined",
"startTimeUtc": "2022-01-30T20:06:38.3979863Z",
"durationInMs": 0.093},
{"event": "Transit Time",
"startTimeUtc": "2022-01-30T20:06:38.3980793Z",
"durationInMs": 1.1643},
{"event": "Received",
"startTimeUtc": "2022-01-30T20:06:38.3992436Z",
"durationInMs": 0.0548},
{"event": "Completed",
"startTimeUtc": "2022-01-30T20:06:38.3992984Z",
"durationInMs": 0}],
"requestSizeInBytes":4346,
"requestBodySizeInBytes":3629,
"responseMetadataSizeInBytes":178,
"responseBodySizeInBytes":60};
ResourceType: Document,
OperationType: Upsert
, Microsoft.Azure.Documents.Common/2.14.0"
}