Dagrooms
Dagrooms

Reputation: 1564

Partition is below target replica or instance count

When attempting to publish a Service Fabric application to a local cluster, the cluster fails to load the application stating the error in the title. The stack trace points me to an exception line in OwinCommunicationListener.cs:

        try
        {
            this.eventSource.LogInfo("Starting web server on " + this.listeningAddress);

            this.webApp = WebApp.Start(this.listeningAddress, appBuilder => this.startup.Invoke(appBuilder));

            this.eventSource.LogInfo("Listening on " + this.publishAddress);

            return Task.FromResult(this.publishAddress);
        }
        catch (Exception ex)
        {
            var logString = $"Web server failed to open endpoint {endpointName}. {ex.ToString()}";
            this.eventSource.LogFatal(logString);

            this.StopWebServer();

            throw ex; // points to this line from cluster manager
        }

I am unable to inspect the exception thrown, but there is no useful exception information other than a TargetInvocationException with a stack trace to the line noted above. Why won't this application load on my local cluster?

Upvotes: 0

Views: 5297

Answers (1)

Vaclav Turecek
Vaclav Turecek

Reputation: 9050

It's hard to say without an actual exception message or stack trace but judging by the location from which the exception was thrown and the fact that the problem resolved itself the next morning, the most likely and most common cause of this is that the port you were trying to use to open the web listener was taken by some other process at the time, and the next morning the port was free again. This, by the way, isn't really specific to Service Fabric. You're just trying to open a socket on a port that was taken by someone else.

I'm honestly more curious about why you couldn't inspect the exception. I can think of three things off the top of my head to help with that:

  1. Use "throw" instead of "throw ex" so you don't reset the stack trace.
  2. Look at your logs. It looks like you're writing out an ETW event in your catch block. What did it say?
  3. Use the Visual Studio debugger: Simply set a breakpoint in the catch block and start the application with debugging by pressing F5.

Upvotes: 1

Related Questions