方便更快捷的说明问题,可以按需填写(可删除)
shardingsphere继承时遇到QuartzScheduler挂起的问题,初步怀疑是
使用环境:
本地开发环境,尝试将shardingsphere集成在公共组件中进行单库分表,项目启动时遇到报错如下(以下报错为从github的issue中找的一样的报错日志,内容基本一致),
`2022-10-20 21:06:39.609 INFO 33576 — [ main] org.quartz.impl.StdSchedulerFactory : Using default implementation for ThreadExecutor
2022-10-20 21:06:39.620 INFO 33576 — [ main] org.quartz.core.SchedulerSignalerImpl : Initialized Scheduler Signaller of type: class org.quartz.core.SchedulerSignalerImpl
2022-10-20 21:06:39.621 INFO 33576 — [ main] org.quartz.core.QuartzScheduler : Quartz Scheduler v.2.3.2 created.
2022-10-20 21:06:39.621 INFO 33576 — [ main] org.quartz.simpl.RAMJobStore : RAMJobStore initialized.
2022-10-20 21:06:39.622 INFO 33576 — [ main] org.quartz.core.QuartzScheduler : Scheduler meta-data: Quartz Scheduler (v2.3.2) ‘quartzScheduler’ with instanceId ‘NON_CLUSTERED’
Scheduler class: ‘org.quartz.core.QuartzScheduler’ - running locally.
NOT STARTED.
Currently in standby mode.
Number of jobs executed: 0
Using thread pool ‘org.quartz.simpl.SimpleThreadPool’ - with 10 threads.
Using job-store ‘org.quartz.simpl.RAMJobStore’ - which does not support persistence. and is not clustered.
2022-10-20 21:06:39.622 INFO 33576 — [ main] org.quartz.impl.StdSchedulerFactory : Quartz scheduler ‘quartzScheduler’ initialized from an externally provided properties instance.
2022-10-20 21:06:39.622 INFO 33576 — [ main] org.quartz.impl.StdSchedulerFactory : Quartz scheduler version: 2.3.2
2022-10-20 21:06:39.622 INFO 33576 — [ main] org.quartz.core.QuartzScheduler : JobFactory set to: org.springframework.scheduling.quartz.SpringBeanJobFactory@33684b87`
程序执行到此处后会挂起,不会执行后续tomcat的初始化
已进行操作:
第一反应时很疑惑,因为我项目里没有用到quartz,所以先排查了下quartz是哪个包引入的,结果发现是shardingsphere-db-discovery中引入的包,我在官网仔细看了下后没发现有相关配置的介绍,我又继续在网上搜索文档,发现了一篇文章如下《 基于 Apache ShardingSphere 构建高可用分布式数据库》,https://www.modb.pro/db/374486,其中提到
1.ShardingSphere 动态发现和更新主从数据库状态的详细流程,同时,为了保证主从状态同步的实时性,高可用模块引入心跳检测机制,通过集成 ShardingSphere 子项目 ElasticJob,在高可用模块初始化时将上述的流程以 Job 的方式交由 ElasticJob 调度框架执行
2.ShardingSphere 高可用的实现依赖于分布式治理的能力,所以目前只支持在集群模式下使用
3.ElasticJob基于quartz做了二次开发
现状:
我本地开发环境应该默认是单机模式吧(参见官方文档https://shardingsphere.apache.org/document/current/cn/user-manual/shardingsphere-jdbc/yaml-config/mode/),我怀疑是因为某些原因,shardingsphere误认为是集群模式,所以开启了特殊的检测???? 我准备明天上班试着配置下
mode:
type: Standalone
repository:
type: JDBC