You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by GitBox <gi...@apache.org> on 2021/11/16 10:02:01 UTC

[GitHub] [shardingsphere-elasticjob] chaletli opened a new issue #487: AbstractDistributeOnceElasticJobListener的doBeforeJobExecutedAtLastStarted执行了多次

chaletli opened a new issue #487:
URL: https://github.com/apache/shardingsphere-elasticjob/issues/487


   Please answer these questions before submitting your issue. Thanks!
   开源不易,我们希望将精力放在完成新功能和解决有价值的问题上,为了让大家的配合更具有效率,请填写以下列出的全部问题
   
   ### Which version of Elastic-Job do you using?(您使用的Elastic-Job版本为?)
   2.1.5
   ### Expected behavior (您预期的结果是)
   加入了AbstractDistributeOnceElasticJobListener的job在集群环境下应该只有一个分片去判断并执行doBeforeJobExecutedAtLastStarted。从类注释“在分布式作业中只执行一次的监听器.”来看应该也是这个意思。
   ### Actual behavior (实际运行的结果是)
   如果在集群下部署多个job实例,通过log打印来看,doBeforeJobExecutedAtLastStarted被执行了多次,即如下的代码中if (guaranteeService.isAllCompleted())被多个实例节点判断都为true
       @Override
       public final void beforeJobExecuted(final ShardingContexts shardingContexts) {
           guaranteeService.registerStart(shardingContexts.getShardingItemParameters().keySet());
           if (guaranteeService.isAllStarted()) {
               doBeforeJobExecutedAtLastStarted(shardingContexts);
               guaranteeService.clearAllStartedInfo();
               return;
           }
           long before = timeService.getCurrentMillis();
           try {
               synchronized (startedWait) {
                   startedWait.wait(startedTimeoutMilliseconds);
               }
           } catch (final InterruptedException ex) {
               Thread.interrupted();
           }
           if (timeService.getCurrentMillis() - before >= startedTimeoutMilliseconds) {
               guaranteeService.clearAllStartedInfo();
               handleTimeout(startedTimeoutMilliseconds);
           }
       }
   ### Steps to reproduce the behavior (可重现问题的操作步骤)
   该问题在线下重现几率较低,生产环境出现概率很高,job的执行周期为每3分钟执行一次。第一次执行时,不会出现多个实例节点都执行doBeforeJobExecutedAtLastStarted的情况,但是从第二次之后,每次都会出现。
   ### Please provide the reproduce example codes (such as github link),otherwise we will label the issue as Invalid and close it.(为了节省复现问题的时间,请务必提供可重现的代码,否则我们会将issue直接标记为invalid并关闭)
   
   Code should based on https://github.com/elasticjob/elastic-job-example
   (代码请基于 https://github.com/elasticjob/elastic-job-example)
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org