Skip to content

Throw exception when asking for FirstWrite OCC without ETag #527

@amolenk

Description

@amolenk

Describe the proposal

Currently, the SDK allows you to make the following call:

await daprClient.SaveStateAsync<Foo>(
    "storename",
    "key",
    new Foo(),
    new StateOptions
    {
        Concurrency = ConcurrencyMode.FirstWrite
    });

The problem with the call is that we're asking Dapr to do something impossible. FirstWrite OCC will only work if we send an ETag along with the request. SaveStateAsync will never send the ETag, for that you need to call TrySaveStateAsync.

The call will succeed but it won't use FirstWrite OCC. There are other situations where you can give Dapr state management a command/hint that cannot be fulfilled by the underlying state store, such as asking for strong consistency if the data store doesn't support it. However, the FirstWrite issue can be caught early at the SDK level.

I propose throwing an exception with a clear message explaining that you need ETag/TrySaveState to use FirstWrite.

Metadata

Metadata

Assignees

No one assigned

    Labels

    kind/bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions