apache / shardingsphere-elasticjob

Distributed scheduled job
Apache License 2.0
8.13k stars 3.28k forks source link

Exception occasionally occurred in OneOffEnabledJobIntegrateTest #2133

Open TeslaCN opened 2 years ago

TeslaCN commented 2 years ago

Bug Report

Which version of ElasticJob did you use?

76199ab2e48875eddf92ef34c6126599869d2205

Expected behavior

All tests passed stably.

Actual behavior

There was error message in logs, but the tests passed.

Running org.apache.shardingsphere.elasticjob.lite.integrate.enable.OneOffEnabledJobIntegrateTest
[ERROR] 2022-10-16 17:17:18,595 --164685539174708_test_job_Worker-1-- [org.quartz.core.JobRunShell] Job DEFAULT.164685539174708_test_job threw an unhandled Exception:  
org.apache.shardingsphere.elasticjob.reg.exception.RegException: java.lang.IllegalStateException: Expected state [STARTED] was [LATENT]
    at org.apache.shardingsphere.elasticjob.reg.exception.RegExceptionHandler.handleException(RegExceptionHandler.java:55)
    at org.apache.shardingsphere.elasticjob.reg.zookeeper.ZookeeperRegistryCenter.isExisted(ZookeeperRegistryCenter.java:213)
    at org.apache.shardingsphere.elasticjob.lite.internal.storage.JobNodeStorage.isJobNodeExisted(JobNodeStorage.java:56)
    at org.apache.shardingsphere.elasticjob.lite.internal.sharding.ExecutionService.getMisfiredJobItems(ExecutionService.java:167)
    at org.apache.shardingsphere.elasticjob.lite.internal.schedule.LiteJobFacade.isExecuteMisfired(LiteJobFacade.java:136)
    at org.apache.shardingsphere.elasticjob.executor.ElasticJobExecutor.execute(ElasticJobExecutor.java:101)
    at org.apache.shardingsphere.elasticjob.lite.internal.schedule.LiteJob.execute(LiteJob.java:35)
    at org.quartz.core.JobRunShell.run(JobRunShell.java:202)
    at org.quartz.simpl.SimpleThreadPool$WorkerThread.run(SimpleThreadPool.java:573)
Caused by: java.lang.IllegalStateException: Expected state [STARTED] was [LATENT]
    at org.apache.curator.shaded.com.google.common.base.Preconditions.checkState(Preconditions.java:823)
    at org.apache.curator.framework.imps.CuratorFrameworkImpl.checkState(CuratorFrameworkImpl.java:423)
    at org.apache.curator.framework.imps.CuratorFrameworkImpl.checkExists(CuratorFrameworkImpl.java:450)
    at org.apache.shardingsphere.elasticjob.reg.zookeeper.ZookeeperRegistryCenter.isExisted(ZookeeperRegistryCenter.java:209)
    ... 7 common frames omitted
[ERROR] 2022-10-16 17:17:18,596 --164685539174708_test_job_Worker-1-- [org.quartz.core.ErrorLogger] Job (DEFAULT.164685539174708_test_job threw an exception. 
org.quartz.SchedulerException: Job threw an unhandled exception.
    at org.quartz.core.JobRunShell.run(JobRunShell.java:213)
    at org.quartz.simpl.SimpleThreadPool$WorkerThread.run(SimpleThreadPool.java:573)
Caused by: org.apache.shardingsphere.elasticjob.reg.exception.RegException: java.lang.IllegalStateException: Expected state [STARTED] was [LATENT]
    at org.apache.shardingsphere.elasticjob.reg.exception.RegExceptionHandler.handleException(RegExceptionHandler.java:55)
    at org.apache.shardingsphere.elasticjob.reg.zookeeper.ZookeeperRegistryCenter.isExisted(ZookeeperRegistryCenter.java:213)
    at org.apache.shardingsphere.elasticjob.lite.internal.storage.JobNodeStorage.isJobNodeExisted(JobNodeStorage.java:56)
    at org.apache.shardingsphere.elasticjob.lite.internal.sharding.ExecutionService.getMisfiredJobItems(ExecutionService.java:167)
    at org.apache.shardingsphere.elasticjob.lite.internal.schedule.LiteJobFacade.isExecuteMisfired(LiteJobFacade.java:136)
    at org.apache.shardingsphere.elasticjob.executor.ElasticJobExecutor.execute(ElasticJobExecutor.java:101)
    at org.apache.shardingsphere.elasticjob.lite.internal.schedule.LiteJob.execute(LiteJob.java:35)
    at org.quartz.core.JobRunShell.run(JobRunShell.java:202)
    ... 1 common frames omitted
Caused by: java.lang.IllegalStateException: Expected state [STARTED] was [LATENT]
    at org.apache.curator.shaded.com.google.common.base.Preconditions.checkState(Preconditions.java:823)
    at org.apache.curator.framework.imps.CuratorFrameworkImpl.checkState(CuratorFrameworkImpl.java:423)
    at org.apache.curator.framework.imps.CuratorFrameworkImpl.checkExists(CuratorFrameworkImpl.java:450)
    at org.apache.shardingsphere.elasticjob.reg.zookeeper.ZookeeperRegistryCenter.isExisted(ZookeeperRegistryCenter.java:209)
    ... 7 common frames omitted

Steps to reproduce the behavior.

./mvnw clean install -T1C
pandaapo commented 2 years ago

I think the probable reason is that there is no closing ZookeeperRegistryCenter in this test case. It may result in the connection to zk being inactive or ineffective during many times test.

linghengqian commented 3 months ago