Reputation: 74
I have a stateful service that stores things in a IReliableDictionary. After deployed to local cluster, I restarted the primary node to test the failover, however, after I do that, the code StateManager.GetOrAddAsync>("MyDictionary") throws FabricNotPrimaryException, then in later trials it throws FabricObjectClosedException. What are some of the things that I can check to troubleshoot this?
Upvotes: 1
Views: 499
Reputation: 106816
The basic way to troubleshoot errors like this is to catch and log the exception being thrown:
try
{
using (var tx = StateManager.CreateTransaction())
{
await dictionary.AddOrUpdateAsync(tx, dto.Id, dto, (key, _) => dto);
await transaction.CommitAsync();
}
}
catch (FabricObjectClosedException ex)
{
ServiceEventSource.Current.Message(ex.ToString());
throw; // Pass the exception up as we only log it here.
}
However, your problem might be a very simple typo like a missing [DataContractAttribute]
on a DTO class. In that case it might be easier to simply debug the problem to quickly understand and fix the problem. To do that you should add the System.Fabric.FabricObjectClosedException
to Visual Studio and then enable "break when thrown" in the debugger:
When a new exception type is added the Break When Thrown check box is already checked.
Next time you execute your application in the debugger the debugger will break when a FabricObjectClosedException
is thrown and you should be able to understand what went wrong.
Upvotes: 1