Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Service Fabric Actor State Actiing Like a Queue

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

like image 772
John Kattenhorn Avatar asked Oct 21 '25 15:10

John Kattenhorn


1 Answers

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.

like image 184
John Kattenhorn Avatar answered Oct 23 '25 03:10

John Kattenhorn