【发布时间】:2018-11-22 03:59:46
【问题描述】:
我正在从与目标存储桶不同的源存储桶发出 S3 CopyObject(又名 PUT 副本)。我想知道在 CopyObject 向 REST 客户端返回 OK 后删除源是否安全。 “安全”是指目标对象最终会出现,并且它最初将包含所有副本发布时可用的数据。
副本中的损坏可能不太可能(鉴于大多数操作是原子的),但是这两个操作相互取消可能是可能的。我希望这些文档对eventual consistency 更加充实。
(在我的场景中,在此期间没有写入源密钥或目标密钥。同一客户端执行复制和删除)。
例如同步伪代码:
try:
# make sure this is a create. read-after-create consistency
my_tmpname = "new_tempfile" + uuid4()
s3_put(data, "s3://my-bucket1/" + my_tmpname)
...
# copy it to its final location
s3_copy("s3://my-bucket1/new_tempfile", "s3://my-bucket2/final_location")
finally:
# Cleanup temp file.
#
# Can this delete interfere with the copy in flight?
# e.g. Should one wait a few seconds/minutes?
# e.g. Should one ensure that the target exists before deleting source?
s3_delete("s3://my-bucket/new_tempfile")
【问题讨论】:
-
它是一个同步调用。只要在复制过程中不从脚本外部删除源文件,就可以了。
标签: amazon-web-services amazon-s3