Netflix/eureka

eureka client not register it self ofter a long time network connection problem

Open

#1,221 opened on 2019年6月22日

GitHub で見る
 (1 comment) (0 reactions) (0 assignees)Java (12,190 stars) (3,712 forks)batch import
bughelp wanted

説明

  1. after a long time network connection problem
  2. client instance is removed from eureka server
  3. renew thread try to send heart beat but eureka server return 404
  4. sendHeartBeat throw TransportException with 404 status code
  5. in the code below, try to re-register client but cause step 4 throw exception, so the re-register logic not executed

boolean renew() {
        EurekaHttpResponse<InstanceInfo> httpResponse;
        try {
            httpResponse = eurekaTransport.registrationClient.sendHeartBeat(instanceInfo.getAppName(), instanceInfo.getId(), instanceInfo, null);
            logger.debug(PREFIX + "{} - Heartbeat status: {}", appPathIdentifier, httpResponse.getStatusCode());
            if (httpResponse.getStatusCode() == Status.NOT_FOUND.getStatusCode()) {
                REREGISTER_COUNTER.increment();
                logger.info(PREFIX + "{} - Re-registering apps/{}", appPathIdentifier, instanceInfo.getAppName());
                long timestamp = instanceInfo.setIsDirtyWithTime();
                boolean success = register();
                if (success) {
                    instanceInfo.unsetIsDirty(timestamp);
                }
                return success;
            }
            return httpResponse.getStatusCode() == Status.OK.getStatusCode();
        } catch (Throwable e) {
            logger.error(PREFIX + "{} - was unable to send heartbeat!", appPathIdentifier, e);
            return false;
        }
    }
  1. Eureka client always retry to send heartbeat with no re-register

コントリビューターガイド