hi, all, I encounter a strange problem in production. A service call B service,B service provide a feign client to A service. sometimes when A service restart, when request comes to A service,A need call B,then A will tell can not find up servers available from load balancer. It not happen every restart situation,but sometime it will happen,I just wonder it may relate to start up initialization order.

I just read eureka code,
eureka client will set up some scheduler in DiscoveryClient constructors

void refreshRegistry() {
        try {
..........

            boolean success = fetchRegistry(remoteRegionsModified);
            if (success) {
                registrySize = localRegionApps.get().size();
                lastSuccessfulRegistryFetchTimestamp = System.currentTimeMillis();
            }
...........

so in refreshRegistry process,eureka client will cache application informations,say B service instances.

when A service call B service,a DynamicServerListLoadBalancer will be initialized,A will choose a B server ip based on Irule(eg roundrobin),all server will be cache in memory by refreshRegistry(it's a scheduler initialized in eureka client constructor),and when a loadbalancer instantiated,it will force ping to initialize the allServerList and upServerList in BaseLoadBalancer.

public BaseLoadBalancer() {
        this.name = DEFAULT_NAME;
        this.ping = null;
        setRule(DEFAULT_RULE);
        setupPingTask();
        lbStats = new LoadBalancerStats(DEFAULT_NAME);
    }
 void setupPingTask() {
        if (canSkipPing()) {
            return;
        }
        if (lbTimer != null) {
            lbTimer.cancel();
        }
        lbTimer = new ShutdownEnabledTimer("NFLoadBalancer-PingTimer-" + name,
                true);
        lbTimer.schedule(new PingTask(), 0, pingIntervalSeconds * 1000);
        forceQuickPing();
    }

when error happens,it tells follow:

Spring Cloud Netflix when will tells no up servers available from load balancer?

I write a feign rule to print some message

@Override
    public Server choose(ILoadBalancer lb, Object key) {
        Server chooseServer = super.choose(lb, key);

        List<Server> reachableServers = lb.getReachableServers();
        List<Server> allServers = lb.getAllServers();
        int upCount = reachableServers.size();
        int serverCount = allServers.size();
        log.info("upCount:{}, serverCount:{}", upCount, serverCount);
        for (Server server : allServers) {
            if (server!=null && server instanceof DiscoveryEnabledServer){
                DiscoveryEnabledServer dServer = (DiscoveryEnabledServer)server;
                InstanceInfo instanceInfo = dServer.getInstanceInfo();
                if (instanceInfo!=null){
                    InstanceInfo.InstanceStatus status = instanceInfo.getStatus();
                    if (status!=null){
                        log.info("server:{}, status:{}", server.getHostPort(), ((DiscoveryEnabledServer) server).getInstanceInfo().getStatus());
                    }
                }
            }
        }

        return chooseServer;
    }

which tells it has server in memory,but no up server.serverCount is 2,but upCount is 0.so it can tell refreshRegistry have fetch instances in memory,but no up server? why?when instantiated a loadBalancer,it will forcePing,so I can not figure out why this problem happens.

when first request fail,the following request will be normal. this situation is not happened every restart time.I just can not figure out why this happend?maybe I lost some informations?

Comment From: ryanjbaxter

I am a little confused by your example. Are you saying you are leaving B running but when you restart A if has the instances of B but they are marked as being DOWN?

Comment From: young001

I am a little confused by your example. Are you saying you are leaving B running but when you restart A if has the instances of B but they are marked as being DOWN?

hi, ryanjbaxter, A service call B, A->B, when A restart, it will can't find available B instance, after some requests(I can't reproduce it),it will call B successfully.I confuse why A restart will can't find B?

Comment From: spencergibb

is this still an issue?

Comment From: spring-projects-issues

If you would like us to look at this issue, please provide the requested information. If the information is not provided within the next 7 days this issue will be closed.

Comment From: spring-projects-issues

Closing due to lack of requested feedback. If you would like us to look at this issue, please provide the requested information and we will re-open the issue.