apache / shardingsphere-elasticjob

Distributed scheduled job
Apache License 2.0
8.15k stars 3.29k forks source link

执行fetchData有数据,但是没有执行processData方法 #51

Closed dzhai closed 8 years ago

dzhai commented 8 years ago

ej版本 1.0.2

日志

第一次查询到复核条件的数据
[03-01 19:29:00,126] INFO  com.qianqian.elasticjob.ActCheckTimer.fetchData(ActCheckTimer.java:43): 活动审核中定时任务开始...... 分片序列号--0--FetchDatSize--1
............
[03-01 19:53:00,119] INFO  com.qianqian.elasticjob.ActCheckTimer.fetchData(ActCheckTimer.java:43): 活动审核中定时任务开始...... 分片序列号--0--FetchDatSize--1
[03-01 19:54:00,111] INFO  com.qianqian.elasticjob.ActCheckTimer.fetchData(ActCheckTimer.java:43): 活动审核中定时任务开始...... 分片序列号--0--FetchDatSize--1
............
重启定时器
[03-01 19:55:00,830] INFO  com.qianqian.elasticjob.ActCheckTimer.fetchData(ActCheckTimer.java:43): 活动审核中定时任务开始...... 分片序列号--0--FetchDatSize--1
[03-01 19:55:00,840] DEBUG com.framelib.aop.DBSourceAspect.doBefore(DBSourceAspect.java:36): switch dataSource to MINE_01 success
[03-01 19:55:00,850] DEBUG org.springframework.transaction.support.AbstractPlatformTransactionManager.getTransaction(AbstractPlatformTransactionManager.java:366): Creating new transaction with name [com.qianqian.service.impl.PrdServiceImpl.modifyActCheck]: PROPAGATION_REQUIRED,ISOLATION_DEFAULT,-java.lang.Exception
[03-01 19:55:00,851] DEBUG org.springframework.jdbc.datasource.DataSourceTransactionManager.doBegin(DataSourceTransactionManager.java:204): Acquired Connection [com.alibaba.druid.proxy.jdbc.ConnectionProxyImpl@de91d1d] for JDBC transaction
[03-01 19:55:00,867] DEBUG org.springframework.jdbc.datasource.DataSourceTransactionManager.doBegin(DataSourceTransactionManager.java:221): Switching JDBC Connection [com.alibaba.druid.proxy.jdbc.ConnectionProxyImpl@de91d1d] to manual commit
[03-01 19:55:00,877] DEBUG org.apache.ibatis.logging.slf4j.Slf4jImpl.debug(Slf4jImpl.java:47): ooo Using Connection [com.alibaba.druid.proxy.jdbc.ConnectionProxyImpl@de91d1d]
[03-01 19:55:00,877] DEBUG org.apache.ibatis.logging.slf4j.Slf4jImpl.debug(Slf4jImpl.java:47): ==>  Preparing: UPDATE prd_product_activity t SET t.status = ? WHERE t.id = ? AND t.end_status = 0 
[03-01 19:55:00,879] DEBUG org.apache.ibatis.logging.slf4j.Slf4jImpl.debug(Slf4jImpl.java:47): ==> Parameters: 23(Integer), 3482933011006518(Long)
[03-01 19:55:01,20] DEBUG org.springframework.transaction.support.AbstractPlatformTransactionManager.processCommit(AbstractPlatformTransactionManager.java:753): Initiating transaction commit
[03-01 19:55:01,20] DEBUG org.springframework.jdbc.datasource.DataSourceTransactionManager.doCommit(DataSourceTransactionManager.java:264): Committing JDBC transaction on Connection [com.alibaba.druid.proxy.jdbc.ConnectionProxyImpl@de91d1d]
[03-01 19:55:01,25] DEBUG org.springframework.jdbc.datasource.DataSourceTransactionManager.doCleanupAfterCompletion(DataSourceTransactionManager.java:322): Releasing JDBC Connection [com.alibaba.druid.proxy.jdbc.ConnectionProxyImpl@de91d1d] after transaction
[03-01 19:55:01,25] DEBUG org.springframework.jdbc.datasource.DataSourceUtils.doReleaseConnection(DataSourceUtils.java:332): Returning JDBC Connection to DataSource
[03-01 19:55:01,25] DEBUG com.framelib.aop.DBSourceAspect.doAfter(DBSourceAspect.java:53): switch dataSource to CLUSTER_01 success
正确执行任务
[03-01 19:55:01,28] INFO  com.qianqian.elasticjob.ActCheckTimer.processData(ActCheckTimer.java:55): 活动审核中任务执行...... 分片序列号--0--活动ID--3482933011006518
[03-01 19:55:01,33] DEBUG com.framelib.aop.DBSourceAspect.doBefore(DBSourceAspect.java:36): switch dataSource to MINE_01 success
[03-01 19:55:01,39] DEBUG org.springframework.jdbc.datasource.DataSourceUtils.doGetConnection(DataSourceUtils.java:110): Fetching JDBC Connection from DataSource
[03-01 19:55:01,39] DEBUG org.apache.ibatis.logging.slf4j.Slf4jImpl.debug(Slf4jImpl.java:47): ooo Using Connection [com.alibaba.druid.proxy.jdbc.ConnectionProxyImpl@de91d1d]
[03-01 19:55:01,40] DEBUG org.apache.ibatis.logging.slf4j.Slf4jImpl.debug(Slf4jImpl.java:47): ==>  Preparing: SELECT t1.`type`,t1.`status` AS prdStatus,t1.`product_code`,t1.`version`,t2.`id` AS actId,t2.`on_time` FROM prd_product t1,prd_product_activity t2 WHERE t1.`product_code` = t2.`product_code` AND t1.`version` = t2.`version` AND t1.`show_flag` = 1 AND t2.`status` = 22 AND t2.`on_time` <= DATE_ADD(DATE_SUB(NOW(),INTERVAL '7' DAY),INTERVAL '00:01:00' HOUR_SECOND) AND t2.id%?=? limit ? 
[03-01 19:55:01,41] DEBUG org.apache.ibatis.logging.slf4j.Slf4jImpl.debug(Slf4jImpl.java:47): ==> Parameters: 1(Integer), 0(Integer), 40(Integer)
[03-01 19:55:01,46] DEBUG org.springframework.jdbc.datasource.DataSourceUtils.doReleaseConnection(DataSourceUtils.java:332): Returning JDBC Connection to DataSource
[03-01 19:55:01,46] DEBUG com.framelib.aop.DBSourceAspect.doAfter(DBSourceAspect.java:53): switch dataSource to CLUSTER_01 success
[03-01 19:55:01,47] INFO  com.qianqian.elasticjob.ActCheckTimer.fetchData(ActCheckTimer.java:43): 活动审核中定时任务开始...... 分片序列号--0--FetchDatSize--0

代码

@Override
    public List<ProductTimer> fetchData(JobExecutionSingleShardingContext shardingContext) {
        List<ProductTimer> timers = prdService.selectActCheck(getDefaultParaMap(shardingContext));
        log.info("活动审核中定时任务开始...... 分片序列号--"+shardingContext.getShardingItem()+"--FetchDatSize--"+getFetchDatSize(timers));
        return timers;
    }

    @Override
    public boolean processData(JobExecutionSingleShardingContext shardingContext, ProductTimer prdTimer) {
        try {
            prdService.modifyActCheck(prdTimer);
        } catch (Exception e) {
            log.error("活动审核中任务执行异常...... 分片序列号--"+shardingContext.getShardingItem()+"--活动ID--"+prdTimer.getActId(),e);
            return false;
        }
        log.info("活动审核中任务执行...... 分片序列号--"+shardingContext.getShardingItem()+"--活动ID--"+prdTimer.getActId());
        return true;
    }

    @Override
    public boolean isStreamingProcess() {

        return true;
    }

配置信息

     <job:bean id="product_checkJob" class="com.qianqian.elasticjob.ActCheckTimer" 
        regCenter="regCenter" 
        cron="0 0/1 * * * ?"
        fetchDataCount="40"
        shardingTotalCount="1"
        shardingItemParameters="0=A"
        overwrite="true"
        description="活动审核中"/>
terrymanu commented 8 years ago

请问是在什么场景下都可以重现么?如果可以,请提供trace日志

dzhai commented 8 years ago

正在跟踪这个问题,重现的时候反馈给你

terrymanu commented 8 years ago

如果未能重现,一周后将关闭此问题

terrymanu commented 8 years ago

版本较旧且长时间不能重现。先关闭了