S3并发写入行为

huangapple go评论58阅读模式
英文:

S3 Concurrent Writes Behavior

问题

上次我查看的时候,S3对于并发写操作存在未定义行为。我正在使用一个强制实现至少一次交付的队列服务,因此有时我会同时对相同前缀进行两次或更多次的并发写入。在完全相同的时间写入相同前缀可能会产生哪些可能的结果?我假设可能发生以下情况:

1)两次写入中的一次成功,从而产生一个新文件。
2)两次写入均不成功,这意味着在S3中没有新文件。

是否存在第三种可能情况,导致S3文件损坏且无法使用?

英文:

Last time I checked, S3 had undefined behavior for concurrent writes. I'm using a queue service that enforces at-least-once delivery so I sometimes end up concurrently writing to the same prefix 2+ times. What possible outcomes could there be from writing to the same prefix at the exact same time? I'm assuming the following cases are possible:

  1. One of the two writes succeeds leading to a new file
  2. Neither of the writes succeeds which means no new file in S3

Is there a 3rd possible case that results in an unusable corrupted S3 file?

答案1

得分: 1

我猜现在仍然没有任何关于S3打算处理这种行为的确认,而且我快速搜索了一下,没有找到任何结果。

你是不是最好自己处理一下?如果S3没有提供任何具体的保证,听起来似乎你的设计需要解决这个问题?每个消息都有一个ID,您可以用它来识别何时收到了重复的消息。我猜您需要在其中使用一套一致的系统,以确保您每个对象只写入S3一次。

英文:

I'm guessing there still isn't any confirmation that S3 is planning on handling this behaviour and a quick search didn't yield any results for me.

Wouldn't you be better off dealing with yourself? If S3 isn't guaranteeing any specifics it sounds like it falls upon your design to solve the problem? Each message has an ID that you can use to recognise when you've received a duplicate. I guess you'll have to use a consistent system in between to guarantee you only write each object to S3 once.

huangapple
  • 本文由 发表于 2020年10月9日 05:27:32
  • 转载请务必保留本文链接:https://go.coder-hub.com/64270856.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定