Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Chassis 2.8.4版本 微服务注册契约丢失问题分析 #4264

Open
yanghao605 opened this issue Mar 9, 2024 · 0 comments
Open

Chassis 2.8.4版本 微服务注册契约丢失问题分析 #4264

yanghao605 opened this issue Mar 9, 2024 · 0 comments

Comments

@yanghao605
Copy link
Contributor

现象:

  1. 首先微服务初次启动时已经成功注册了,且契约正常;
  2. 微服务提供了一个接口,可以检查自身的调用链状态,大致逻辑为自己调用自己的health接口
  3. 将心跳的间隔时间调至1s(为了加大异常出现的概率),先调用一次2中的接口,此时会将自身微服务的契约缓存到schemaCache中,然后通过调用注册中心接口或者是页面上删除微服务信息;
  4. 微服务重新注册之后(未重启),在页面上发现微服务的契约丢失,其它服务无法正常调用该服务

原因分析:

  1. chassis中提供来了一个schemaCache由于缓存微服务契约,依据serviceId和schemaId进行存储,缓存的有效期为60s,也就说在60s内,获取契约时,会优先获取schemaCache中的契约,只有当缓存为空或者契约已过期才会重新从注册中心获取契约;
  2. 而当存在微服务调用自身接口的场景时,schemaCache中也就缓存下来了微服务本身的契约信息
  3. 而若是恰巧在此时,注册中心的微服务信息被删除,导致微服务重新注册时,且一般情况下生成的微服务serivceId是不变的,也就导致在进行微服务契约注册,进行summary比较时,即使从注册中心获取的summary为空,而在从注册中心获取详细契约生成summary时,优先获取的是schemaCache中的契约,也就导致实际注册中心没有相关的契约信息,但是微服务在注册时的感知却是注册中心已经存在该契约信息,从而导致微服务不再注册该契约信息。
  4. 最终导致的结果即为注册中心的微服务契约信息部分丢失甚至全部丢失。
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant