-
Notifications
You must be signed in to change notification settings - Fork 1.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
'blank' etag is treated as "no etag" #2320
Comments
Ok, some additional details thanks to @youngbupark Currently, Dapr treats inserts as "upserts" which create a the value if nothing exists (or no/blank etag is provided). So, in this case, where there is no etag on first request, later requests are treated as overwrites, which is not intuitive. Using pseudo-code:
|
To be clear, the user's expectation (I believe) would be around 'optimistic concurrency':
This could be addressed via metadata settings - e.g. https://azure.microsoft.com/en-us/blog/managing-concurrency-in-microsoft-azure-storage-2/ |
I agree there’s something missing in the way Dapr works with OCC right now. Not sure if it's a design issue or a bug, but it definitely should be looked at. Let’s say there are multiple users working on a set of articles. Using Dapr first-write-wins and ETags we can be sure that no user overwrites the work of another user:
This works great. However, if you start from a situation where there isn't any state saved yet and the users create new articles, Dapr’s OCC mechanism breaks down:
In the sample above, user 2 will always overwrite the key/value stored by user 1 because Dapr interprets the blank ETag as “there’s no ETag, so I won’t use first-write-wins”. For OCC to work in all scenarios, we need a distinction between a blank ETag and a missing ETag. Blank ETag = first-write-wins, only save state if it doesn’t exist yet |
I strongly disagree to this solution: make blank and missing to totally different meaning is very very tricky to the user. This is always NOT a good idea. I summit a issue to discuss this and bring with two better solution: #2739 |
/area runtime
What version of Dapr?
0.8
When using the following write to state store (redis), if I set the value of
etag
to be '' (blank), dapr treats this as having no etag.This is not ideal. If this was in a thread where multiple threads read a value that did not exist, and then all tried to write it simultaneously, every one but the first write should fail from an etag mismatch.
RELEASE NOTE: FIX Bug in runtime.
The text was updated successfully, but these errors were encountered: