tmaj
tmaj

Reputation: 35017

The primary or stateless instance for the partition has invalid address

I created a stateful service with the out-of-the-box partitioning:

<StatefulService ServiceTypeName="ExamplesServiceType" TargetReplicaSetSize="[ExamplesService_TargetReplicaSetSize]" MinReplicaSetSize="[ExamplesService_MinReplicaSetSize]">
            <UniformInt64Partition PartitionCount="[ExamplesService_PartitionCount]" LowKey="-9223372036854775808" HighKey="9223372036854775807" />
         </StatefulService>

The service manifest sets the params to (out-of-the-box as well):

 <Parameter Name="ExampleService_PartitionCount" Value="1" />
 <Parameter Name="ExampleService_MinReplicaSetSize" Value="2" />
 <Parameter Name="ExampleService_TargetReplicaSetSize" Value="3" />
 <Parameter Name="WebService_InstanceCount" Value="1" />

Now I want to call to to my stateful service from my stateless service in the same cluster:

 ServiceUriBuilder builder = new ServiceUriBuilder(ExampleServiceName);
 var service = ServiceProxy.Create<IExampleService>(builder.ToUri(),new ServicePartitionKey(1));

 return service.MyCallAsync(id);

I'm getting the following error:

The primary or stateless instance for the partition 'a67f7afa-3370-4e6f-ae7c-15188004bfa1' has invalid address, this means that right address from the replica/instance is not registered in the system

The stateful service I'm trying to reach logs to the event logs and the logs carry "partitionId": "a67f7afa-3370-4e6f-ae7c-15188004bfa1".

What am I missing?

Upvotes: 20

Views: 5530

Answers (3)

David Klempfner
David Klempfner

Reputation: 9870

For those of you using Microsoft.ServiceFabric.Services.Remoting version 3.3.638, I found that there was no extension method called CreateServiceInstanceListeners(). I only found CreateServiceRemotingInstanceListeners() and CreateServiceRemotingReplicaListeners() in Microsoft.ServiceFabric.Services.Remoting.Runtime.ServiceRemotingExtensions.

This code compiled for me:

    protected override IEnumerable<ServiceInstanceListener> CreateServiceInstanceListeners()
    {
        return this.CreateServiceRemotingInstanceListeners();
    }

Upvotes: 3

KPERI
KPERI

Reputation: 233

In case anyone else comes here wondering what to do for stateless services, this works for me:

protected override IEnumerable<ServiceInstanceListener> CreateServiceInstanceListeners()
{
    return new[] { new ServiceInstanceListener(context => this.CreateServiceRemotingListener(context)) };
}

Upvotes: 11

tmaj
tmaj

Reputation: 35017

I wasn't registering a remote as explained at http://vunvulearadu.blogspot.com/2016/04/azure-service-fabric-primary-or.html

        protected override IEnumerable<ServiceReplicaListener> CreateServiceReplicaListeners()
    {
        return new[] { new ServiceReplicaListener(context => this.CreateServiceRemotingListener(context)) };
    }

Upvotes: 30

Related Questions