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/03 12:19:49 UTC

[GitHub] [shardingsphere-elasticjob] wujiuye opened a new issue #2005: The exception information of the previous slice execution is not cleared

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


   ## Bug Report
   
   If the current task fails to execute, even if the next execution is successful, the event tracking will get the exception information of the previous execution failure. The exception will only be overwritten and will not be deleted.
   
   ### Which version of ElasticJob did you use?
   
   Release Version: 3.0.0
   
   Master branch not repaired.
   
   ### Which project did you use? ElasticJob-Lite or ElasticJob-Cloud?
   
   ElasticJob-Lite
   
   ### Reason analyze 
   
   Cause: the exception information of the last execution was not cleared.
   
   org.apache.shardingsphere.elasticjob.executor.ElasticJobExecutor#execute
   ```java
   private void execute(JobConfiguration jobConfig, ShardingContexts shardingContexts, ExecutionSource executionSource) {
           if (shardingContexts.getShardingItemParameters().isEmpty()) {
               this.jobFacade.postJobStatusTraceEvent(shardingContexts.getTaskId(), State.TASK_FINISHED, String.format("Sharding item for job '%s' is empty.", jobConfig.getJobName()));
           } else {
               this.jobFacade.registerJobBegin(shardingContexts);
               String taskId = shardingContexts.getTaskId();
               this.jobFacade.postJobStatusTraceEvent(taskId, State.TASK_RUNNING, "");
   
               try {
                   this.process(jobConfig, shardingContexts, executionSource);
               } finally {
                   this.jobFacade.registerJobCompleted(shardingContexts);
                   if (this.itemErrorMessages.isEmpty()) {
                       this.jobFacade.postJobStatusTraceEvent(taskId, State.TASK_FINISHED, "");
                   } else {
                       this.jobFacade.postJobStatusTraceEvent(taskId, State.TASK_ERROR, this.itemErrorMessages.toString());
                   }
                   //  It is recommended to clear itemerrormessages here
               }
   
           }
       }
   ```
   
   


-- 
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



[GitHub] [shardingsphere-elasticjob] wujiuye commented on issue #2005: The exception information of the previous slice execution is not cleared

Posted by GitBox <gi...@apache.org>.
wujiuye commented on issue #2005:
URL: https://github.com/apache/shardingsphere-elasticjob/issues/2005#issuecomment-958979376


   This can be reproduced:
   ```
   public class JavaSimpleJob implements SimpleJob {
   
       private final FooRepository fooRepository = FooRepositoryFactory.getFooRepository();
   
       @Override
       public void execute(final ShardingContext shardingContext) {
           if (shardingContext.getShardingItem() == System.currentTimeMillis()%shardingContext.getShardingTotalCount()) {
               throw new NullPointerException("java simple job null " + System.currentTimeMillis());
           }
           System.out.printf("Item: %s | Time: %s | Thread: %s | %s%n",
                   shardingContext.getShardingItem(), new SimpleDateFormat("HH:mm:ss").format(new Date()), Thread.currentThread().getId(), "SIMPLE");
           List<Foo> data = fooRepository.findTodoData(shardingContext.getShardingParameter(), 10);
           for (Foo each : data) {
               fooRepository.setCompleted(each.getId());
           }
       }
   }
   ```


-- 
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



[GitHub] [shardingsphere-elasticjob] wujiuye commented on issue #2005: The exception information of the previous slice execution is not cleared

Posted by GitBox <gi...@apache.org>.
wujiuye commented on issue #2005:
URL: https://github.com/apache/shardingsphere-elasticjob/issues/2005#issuecomment-958979376


   This can be reproduced:
   ```
   public class JavaSimpleJob implements SimpleJob {
   
       private final FooRepository fooRepository = FooRepositoryFactory.getFooRepository();
   
       @Override
       public void execute(final ShardingContext shardingContext) {
           if (shardingContext.getShardingItem() == System.currentTimeMillis()%shardingContext.getShardingTotalCount()) {
               throw new NullPointerException("java simple job null " + System.currentTimeMillis());
           }
           System.out.printf("Item: %s | Time: %s | Thread: %s | %s%n",
                   shardingContext.getShardingItem(), new SimpleDateFormat("HH:mm:ss").format(new Date()), Thread.currentThread().getId(), "SIMPLE");
           List<Foo> data = fooRepository.findTodoData(shardingContext.getShardingParameter(), 10);
           for (Foo each : data) {
               fooRepository.setCompleted(each.getId());
           }
       }
   }
   ```


-- 
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



[GitHub] [shardingsphere-elasticjob] wujiuye commented on issue #2005: The exception information of the previous slice execution is not cleared

Posted by GitBox <gi...@apache.org>.
wujiuye commented on issue #2005:
URL: https://github.com/apache/shardingsphere-elasticjob/issues/2005#issuecomment-958979376






-- 
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