【以下的问题经过翻译处理】 我发现一个罕见的竞态条件。有时,如果我更新基于镜像的 Lambda 以具有新的镜像,则触发 Lambda 的 API Gateway api 将返回以下错误:
(f654758f-d377-4222-a4c3-766325f0de32) Lambda invocation failed with status: 409. Lambda request id: 1e69c921-26ce-4c4d-81ad-183264a08c59
(f654758f-d377-4222-a4c3-766325f0de32) Execution failed due to configuration error: The operation cannot be performed at this time. The function is currently in the following state: Pending
(f654758f-d377-4222-a4c3-766325f0de32) Method completed with status: 500
这是导致竞态条件发生的更新 Lambda 的方法:
# 将新的 Docker 镜像发布到函数
aws lambda update-function-code --publish --function-name "$name" --image-uri "$image"
# 将别名更新为新发布的版本
aws lambda update-alias --name "$stage" --function-name "$name" --function-version "$version"
我一定是做错了什么,因为如果无法原子性地更新 Lambda 镜像或别名,则无法可靠地部署。