baomidou / dynamic-datasource

dynamic datasource for springboot 多数据源 动态数据源 主从分离 读写分离 分布式事务
https://www.kancloud.cn/tracy5546/dynamic-datasource/2264611
Apache License 2.0
4.74k stars 1.19k forks source link

springboot actuator/health健康检查异常 #293

Closed dragon-twister closed 4 years ago

dragon-twister commented 4 years ago

Enviroment

JDK Version(1.8):

SpringBoot Version(2.3.4):

dynamic-datasource-spring-boot-starter Version(3.2.1):

druid Version(1.2.1):

Describe

访问springboot健康检查异常,出现表达式: "status":{"$ref":"$.components.db.status"}

Expected Result:

{"status":"UP","components":{"db":{"status":"UP","details":{"database":"MySQL","validationQuery":"isValid()"}},"discoveryComposite":{"description":"Discovery Client not initialized","status":"UNKNOWN","components":{"discoveryClient":{"description":"Discovery Client not initialized","status":"UNKNOWN"}}},"diskSpace":{"status":"UP","details":{"total":501731028992,"free":486095646720,"threshold":10485760,"exists":true}},"hystrix":{"status":"UP"},"ping":{"status":"UP"},"redis":{"status":"UP","details":{"version":"3.2.11"}},"refreshScope":{"status":"UP"}}}

Actual Result:
{"components":{"db":{"details":{"database":"MySQL","validationQuery":"isValid\u0028\u0029"},"status":{"code":"UP","description":""}},"discoveryComposite":{"components":{"discoveryClient":{"details":{},"status":{"code":"UNKNOWN","description":"Discovery Client not initialized"}}},"status":{"$ref":"$.components.discoveryComposite.components.discoveryClient.status"}},"diskSpace":{"details":{"total":501731028992,"free":486095646720,"threshold":10485760,"exists":true},"status":{"$ref":"$.components.db.status"}},"hystrix":{"details":{},"status":{"$ref":"$.components.db.status"}},"ping":{"details":{},"status":{"$ref":"$.components.db.status"}},"redis":{"details":{"version":"3.2.11"},"status":{"$ref":"$.components.db.status"}},"refreshScope":{"details":{},"status":{"$ref":"$.components.db.status"}}},"groups":[],"status":{"$ref":"$.components.db.status"}}

Steps to reproduce

huayanYu commented 4 years ago
  1. 无法复现,示例项目 https://github.com/dynamic-datasource/dynamic-datasource-samples/tree/master/druid-sample

  2. 默认的db健康检查org.springframework.boot.actuate.jdbc.DataSourceHealthIndicator 只能检查主数据源。 多数据源需要自己实现。

也可以讨论多数据源怎么样才算健康,可以贡献代码参考一下。

huayanYu commented 4 years ago

无反馈,关闭。