Troubleshooting ServiceFabric StatefulService Deployment

时间:2016-08-31 17:40:52

标签: azure-service-fabric service-fabric-stateful

Working with a stateful service in ServiceFabric version 5.1.163.9590, I am attempting to deploy a demo application with three WebApi services that manage their own state.

Two of the three services start and create their partitions without errors, but the last spews events a series of warnings and errors, the error detail has this intriguing message:

   Microsoft.ServiceFabric.Replicator.LoggingReplicator : GetCopyState The parameter copyContext is null. This might be caused by deployment bug that 'hasPersistedState' attribute is false. 

I can't locate any external references to this error message.

Is there a way to correct this from the application and service deployment side, or from the cluster management side?

1 个答案:

答案 0 :(得分:2)

The error indicates you have a stateful service with persisted state, but didn't tell Service Fabric about that when you deployed the service.

There's a flag that needs to be set to indicate to Service Fabric that a stateful service has persisted state (as opposed to state that is "volatile," meaning in-memory only).

In your ServiceManifest.xml, make sure you have this flag set on the service type:

  <ServiceTypes>
      <StatefulServiceType ServiceTypeName="MyServiceType" HasPersistedState="true" />
  </ServiceTypes>

Then if you're deploying through PowerShell, make sure you set this flag when you create an instance of the service:

PS > New-ServiceFabricService -Stateful -HasPersistedState -ServiceTypeName "MyServiceType" ...