简体   繁体   English

DynamoDB ConditionalCheckFailedException 抛出但成功

[英]DynamoDB ConditionalCheckFailedException thrown but succeeds

I think that have seen in many occasions that a DynamoDB conditional put throws ConditionalCheckFailedException but succeeds.我认为在很多情况下都看到 DynamoDB 条件放置抛出 ConditionalCheckFailedException 但成功了。 Usually in this scenario, the request takes quite long (~10s) to finish, but I can see that the request is updated despite the fact that a ConditionalCheckFailedException is thrown (and the it took few seconds).通常在这种情况下,请求需要很长时间(~10 秒)才能完成,但我可以看到请求已更新,尽管抛出了 ConditionalCheckFailedException(并且花费了几秒钟)。

By the way I don't force any timeout on the DDB request.顺便说一下,我不会强制 DDB 请求超时。

Is this a bug, or some DDB conditional put contract that I misunderstand?这是一个错误,还是我误解了某些 DDB 条件看跌合约? Has anyone experienced this issue?有没有人遇到过这个问题?

Answering this late to inform others:这么晚回答是为了通知其他人:

ConditionCheckFailedException but item is persisted: ConditionCheckFailedException但项目被保留:

This typically happens when you save an item to DynamoDB, DynamoDB acknowledges the write request but the response gets lost on the return path which can happen for multiple reasons, keeping in mind that DynamoDB is one of the largest distributed systems in the cloud.这通常发生在您将项目保存到 DynamoDB 时,DynamoDB 确认写入请求但响应在返回路径上丢失,这可能由于多种原因而发生,请记住 DynamoDB 是云中最大的分布式系统之一。

This causes the SDK timeout to exceed while awaiting a response, which then triggers an SDK retry.这会导致 SDK 在等待响应时超时,然后触发 SDK 重试。 When the write request is retried, the condition now evaluates to False as the item already exists, which in turn throws a ConditionCheckFailedException , which can cause confusion.当重试写入请求时,条件现在评估为False ,因为该项目已经存在,这又会抛出ConditionCheckFailedException ,这可能会导致混淆。

When I receive a ConditionCheckFailedException I typically do a strongly consistent GetItem request for the item to ensure it exists with the values I expect and move on.当我收到ConditionCheckFailedException时,我通常会对该项目执行高度一致的GetItem请求,以确保它存在我期望的值并继续。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM