top | item 38510494

(no title)

wombarly | 2 years ago

Couldn't the library implement a conditional operation using the etag, retrying if it fails? That should solve the consistency guarantee.

Ofc its a different matter if you write to the same key in the same file. But that could be solved with special method that allows you to do a setOrUpdate on a key in the json and when retrying the update method is executed again (allowing you to do increments or add a new item to an array) while guaranteeing consistency.

discuss

order

danielheath|2 years ago

Consider the case of two workers both trying to write the same key at once. Which one should succeed?

wombarly|2 years ago

If you use etags it's up to R2. I'm assuming R2 is consistent here.

So if you write to the same file twice, one write will succeed before the other and change the etag of the file, which should in theory cause the other request to R2 to fail because the etag you send with as conditional no longer matches.

neon_me|2 years ago

Its up to your implementation. Which is very similar to any other "average" database ...