I have a Actor Method which looks like this:
ConditionalValue<Command> result = await this.StateManager.TryGetStateAsync<Command>(key);
await this.StateManager.TryRemoveStateAsync(key);
return result.Value;
When I return from the ActorMethod or call this.SaveStateAsync(), it throws with the following exception:
System.Fabric.FabricException: The given key was not present. ---> System.Runtime.InteropServices.COMException: Exception from HRESULT: 0x80071C13
at System.Fabric.Interop.NativeRuntime.IFabricKeyValueStoreReplica6.Remove
All day I spent on this and then I figured it out.
In another method of the same actor we enqueue the item that get deleted in the other method call.
By looking at the StateManager I could see that the value had a CheckStatus of Add, so I added the follow call into the enqueue method
await this.SaveStateAsync();
And the de-queue then worked without any issues.
It's probably an edge case but don't do an Add in one method, a retrieve and delete in another method, without saving state in between.
Reminded me a bit of EF Context.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With