2014-07-08 1 views
1

, 슬레이브 쓰레드의 각은 아래의 오류와 함께 실패 파티션 봄 일괄 작업을 실행하는 동안 : 다중 쓰레드 스텝을위한 threadsafe의 JobRepository는 무엇입니까?

[SimpleAsyncTaskExecutor-2] AbstractStep.execute(250) | Encountered an error saving batch meta data. This job is now in an unknown state and should not be restarted. org.springframework.dao.OptimisticLockingFailureException: Attempt to update step execution id=4623 with wrong version (1), where current version is 2 at org.springframework.batch.core.repository.dao.JdbcStepExecutionDao.updateStepExecution(JdbcStepExecutionDao.java:185) at org.springframework.batch.core.repository.support.SimpleJobRepository.update(SimpleJobRepository.java:171)

작업 저장소를 사용하고

는 JobRepositoryFactoryBean이다. 스프링 배치 버전은 2.1.8입니다. BATCH_STEP_EXECUTION 테이블에서 모든 단계에 대해 단계를 처음 실행하는 동안에도 버전은 2입니다. 아래

작업 구성 :

<job id="partitionJob" xmlns="http://www.springframework.org/schema/batch" parent="simpleJob"> 
    <step id="masterStep" xmlns="http://www.springframework.org/schema/batch" parent="skipLimitStep"> 
     <partition step="slave" partitioner="BulkPartitioner" xmlns="http://www.springframework.org/schema/batch"> 
     <handler grid-size="10" task-executor="asyncTaskExecutor" xmlns="http://www.springframework.org/schema/batch" /> 
     </partition> 
    </step> 
</job> 

<step id="slave" xmlns="http://www.springframework.org/schema/batch" parent="skipLimitStep"> 
    <tasklet> 
     <chunk reader="partitionPagingItemReader" writer="partitionItemWriter" commit-interval="1" processor="partitionitemProcessor" skip-limit="1000"> 
     </chunk> 
     <transaction-attributes propagation="REQUIRES_NEW" /> 
    </tasklet> 
</step> 

<bean id="BulkPartitioner" class="foo.bar.BulkPartitioner" scope="step" > 
    <property name="model" value="#{jobParameters['abc']}"/> 
</bean> 

<bean id="partitionPagingItemReader" class="org.springframework.batch.item.database.JdbcPagingItemReader" scope="step" > 
    <property name="dataSource" ref="dataSource" /> 
    <!-- <property name="fetchSize" value="#{jobParameters['fetch.size']}"></property> --> 
    <property name="fetchSize" value="1000"></property> 
    <property name="queryProvider"> 
     <bean class="org.springframework.batch.item.database.support.SqlPagingQueryProviderFactoryBean"> 
      <property name="dataSource" ref="dataSource" /> 
      <property name="selectClause" value="select a, b, c" /> 
      <property name="fromClause" value="from d" /> 
      <property name="whereClause" value="where e= :f" /> 
      <property name="sortKey" value="e" /> 
     </bean> 
    </property> 
    <!-- Inject via the ExecutionContext in rangePartitioner --> 
    <property name="parameterValues"> 
     <map> 
      <entry key="f" value="#{stepExecutionContext[f]}" /> 
     </map> 
    </property> 
    <property name="pageSize" value="1" /> 
    <property name="rowMapper"> 
     <bean class="foo.bar.mapper" /> 
    </property> 
</bean> 

<bean id="simpleJob" 
     class="org.springframework.batch.core.job.SimpleJob" abstract="true"> 
    <property name="jobRepository" ref="jobRepository"/> 
    <property name="restartable" value="true"/> 
</bean> 

<bean id="jobRepository" 
     class="org.springframework.batch.core.repository.support.JobRepositoryFactoryBean"> 
    <property name="dataSource" ref="dataSource"/> 
    <property name="databaseType" value="oracle"/> 
    <property name="transactionManager" ref="transactionManager"/> 
    <property name="isolationLevelForCreate" value="ISOLATION_DEFAULT"/> 
    <property name="validateTransactionState" value="false"/> 
</bean> 

갱신 : 이것은 실패한 단계에서만 일어나고있다. 단계의 성공적인 완료가 올바르게 갱신됩니다.

무엇이 원인 일 수 있습니까? TIA.

<property name="saveState" value="false" /> 

동시 작업/단계에 대한 독자 (들)/작가 (들) :

+0

어떤 데이터베이스를? 어떻게 구성됩니까? –

+0

작업 구성으로 게시물이 업데이트되었습니다. 사용 된 데이터베이스는 Oracle 11g입니다. –

+0

기본 트랜잭션 전파를 재정의하는 이유가 있습니까? –

답변

관련 문제