0

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?

Tetsujin no Oni
  • 7,300
  • 2
  • 29
  • 46

1 Answers1

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" ...
Vaclav Turecek
  • 9,020
  • 24
  • 29