Eureka - Eureka client 注册到 Server中一直保持STARTING状态的问题。

问题描述

Eureka Client注册到Eureka Server后,一直保持着STARTING状态,一直不会变为UP状态。

环境版本信息

spring-boot:2.0.6.RELEASE

spring-cloud-dependencies:Finchley.SR2

问题排查

在GitHub上找到了对应的问题 Instance status keep STARTING in eureka server even it is UP on Local,经过科普后,得知出现这种问题的概率是极低的,但是我遇到的场景是100%必现。再次仔细阅读后发现如下说明

Why this happens

Both DiscoveryClient and EurekaAutoServiceRegistration are initialized in EurekaClientAutoConfiguration. The latter depends on the former.

HeartbeatThread thread is started delay: eureka.instance.lease-renewal-interval-in-seconds can be used to configure delay time. Default is 30s, In our case it is configured as 10s.

This means there is race condition between Main flow and Heartbeat thread. Duration registration in heartbeat thread, it serializes instance info to JSON which gets its status first, then lastDirtyTimestamp. Between them, Main flow does status change in EurekaRegistration#register().

Further, EurekaAutoServiceRegistration#start() is invoked after all bean initialized. This means the cost is up to 10s for all beans' initialization.

后来经过仔细排查,发现应用中一个实现了org.springframework.boot.CommandLineRunner的子类,在项目启动期间,解析Reids缓存中的数据过程中,因为数据结构的异常,导致解析失败。修复该问题后,Eureka Client注册到Eureka Server一切正常。

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值