Spring batch - causing possible deadlock -
i have batch job multiple steps. each step involves reading 5-6 tables joined, , writing report_table. in step 8, after reading , writing 450000 records, failed exception - caused by: java.sql.sqlexception: not indexed read next row. understand exception caused deadlock. there no other step running in parallel , step that's writing report_table. have caused deadlock ? on time crunch finish job , appreciated.
structure of job
- step1
- step2 split [ step2a, step2b ] running in parallel
- step 3
- step4 split [ step4a , step4b, step 4c] running in parallel
- step5 split [ step5a , step5b, step 5c] running in parallel
- step6
- step7
- step8
- step9
my configuration follows :
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/xmlschema-instance" xsi:schemalocation=" http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.2.xsd"> <bean id="transactionmanager" class="org.springframework.jdbc.datasource.datasourcetransactionmanager" lazy-init="true"> <property name="datasource" ref="datasource" /> </bean> <bean id="batchdefaultserializer" class="org.springframework.batch.core.repository.dao.defaultexecutioncontextserializer" /> <bean id="informixincrementer" class="com.bah.batch.informixsupport.informixmaxvalueincrementerfactory"> <property name="datasource" ref="datasource" /> </bean> <bean id="datasource" class="org.apache.commons.dbcp.basicdatasource"> <property name="driverclassname" value="com.informix.jdbc.ifxdriver"/> <property name="url" value="<url>" /> <property name="username" value="<username>" /> <property name="password" value="<password>" /> <property name="initialsize" value="10" /> <property name="maxidle" value="5" /> <property name="minidle" value="5" /> <property name="maxactive" value="10" /> <property name="maxwait" value="3000" /> <property name="removeabandonedtimeout" value="1800" /> <property name="logabandoned" value="true" /> </bean> <bean id="jobrepository" class="com.bah.batch.informixsupport.informixjobrepositoryfactorybean"> <property name="datasource" ref="datasource" /> <property name="databasetype" value="informix"/> <property name="incrementerfactory" ref="informixincrementer"/> <property name="transactionmanager" ref="transactionmanager"/> <property name="tableprefix" value="bhi:batch_" /> </bean> </beans>
here stack trace :
encountered fatal error executing job
**org.springframework.batch.core.jobexecutionexception: flow execution ended unexpectedly @ org.springframework.batch.core.job.flow.flowjob.doexecute(flowjob.java:140)** @ org.springframework.batch.core.job.abstractjob.execute(abstractjob.java:304) @ org.springframework.batch.core.launch.support.simplejoblauncher$1.run(simplejoblauncher.java:135) @ org.springframework.core.task.synctaskexecutor.execute(synctaskexecutor.java:50) @ org.springframework.batch.core.launch.support.simplejoblauncher.run(simplejoblauncher.java:128) @ com.bah.discrepancy.init.initiatepurchasereport.main(initiatepurchasereport.java:76) **caused by: org.springframework.batch.core.job.flow.flowexecutionexception: ended flow=itemcodesplit.2 @ state=itemcodesplit.2.itemlevelitems exception @ org.springframework.batch.core.job.flow.support.simpleflow.resume(simpleflow.java:174)** @ org.springframework.batch.core.job.flow.support.simpleflow.start(simpleflow.java:144) @ org.springframework.batch.core.job.flow.support.state.splitstate$1.call(splitstate.java:93) @ org.springframework.batch.core.job.flow.support.state.splitstate$1.call(splitstate.java:90) @ java.util.concurrent.futuretask$sync.innerrun(futuretask.java:303) @ java.util.concurrent.futuretask.run(futuretask.java:138) @ org.springframework.core.task.simpleasynctaskexecutor$concurrencythrottlingrunnable.run(simpleasynctaskexecutor.java:251) @ java.lang.thread.run(thread.java:662) caused by: org.springframework.jdbc.uncategorizedsqlexception: preparedstatementcallback; uncategorized sqlexception sql [update bhi:batch_job_execution_context set short_context = ?, serialized_context = ? **where job_execution_id = ?]; sql state [ix000]; error code [-244]; not physical-order read fetch next row.; nested exception java.sql.sqlexception: not physical-order read fetch next row.** @ org.springframework.jdbc.support.abstractfallbacksqlexceptiontranslator.translate(abstractfallbacksqlexceptiontranslator.java:84) @ org.springframework.jdbc.support.abstractfallbacksqlexceptiontranslator.translate(abstractfallbacksqlexceptiontranslator.java:81) @ org.springframework.jdbc.support.abstractfallbacksqlexceptiontranslator.translate(abstractfallbacksqlexceptiontranslator.java:81) @ org.springframework.jdbc.core.jdbctemplate.execute(jdbctemplate.java:660) @ org.springframework.jdbc.core.jdbctemplate.update(jdbctemplate.java:909) @ org.springframework.jdbc.core.jdbctemplate.update(jdbctemplate.java:970) @ org.springframework.batch.core.repository.dao.jdbcexecutioncontextdao.persistserializedcontext(jdbcexecutioncontextdao.java:233) @ org.springframework.batch.core.repository.dao.jdbcexecutioncontextdao.updateexecutioncontext(jdbcexecutioncontextdao.java:146) @ org.springframework.batch.core.repository.support.simplejobrepository.updateexecutioncontext(simplejobrepository.java:210) @ sun.reflect.nativemethodaccessorimpl.invoke0(native method) @ sun.reflect.nativemethodaccessorimpl.invoke(nativemethodaccessorimpl.java:39) @ sun.reflect.delegatingmethodaccessorimpl.invoke(delegatingmethodaccessorimpl.java:25) @ java.lang.reflect.method.invoke(method.java:597) @ org.springframework.aop.support.aoputils.invokejoinpointusingreflection(aoputils.java:317) @ org.springframework.aop.framework.reflectivemethodinvocation.invokejoinpoint(reflectivemethodinvocation.java:190) @ org.springframework.aop.framework.reflectivemethodinvocation.proceed(reflectivemethodinvocation.java:157) @ org.springframework.transaction.interceptor.transactioninterceptor$1.proceedwithinvocation(transactioninterceptor.java:98) @ org.springframework.transaction.interceptor.transactionaspectsupport.invokewithintransaction(transactionaspectsupport.java:262) @ org.springframework.transaction.interceptor.transactioninterceptor.invoke(transactioninterceptor.java:95) @ org.springframework.aop.framework.reflectivemethodinvocation.proceed(reflectivemethodinvocation.java:179) @ org.springframework.aop.framework.jdkdynamicaopproxy.invoke(jdkdynamicaopproxy.java:207) @ $proxy2.updateexecutioncontext(unknown source) @ org.springframework.batch.core.job.simplestephandler.handlestep(simplestephandler.java:159) @ org.springframework.batch.core.job.flow.jobflowexecutor.executestep(jobflowexecutor.java:64) @ org.springframework.batch.core.job.flow.support.state.stepstate.handle(stepstate.java:67) @ org.springframework.batch.core.job.flow.support.simpleflow.resume(simpleflow.java:165) ... 7 more caused by: java.sql.sqlexception: not physical-order read fetch next row. @ com.informix.jdbc.ifxsqli.a(ifxsqli.java:3453) @ com.informix.jdbc.ifxsqli.e(ifxsqli.java:3770) @ com.informix.jdbc.ifxsqli.dispatchmsg(ifxsqli.java:2576) @ com.informix.jdbc.ifxsqli.receivemessage(ifxsqli.java:2492) @ com.informix.jdbc.ifxsqli.executecommand(ifxsqli.java:940) @ com.informix.jdbc.ifxresultset.b(ifxresultset.java:300) @ com.informix.jdbc.ifxstatement.c(ifxstatement.java:1272) @ com.informix.jdbc.ifxpreparedstatement.executeupdate(ifxpreparedstatement.java:415) @ org.apache.commons.dbcp.delegatingpreparedstatement.executeupdate(delegatingpreparedstatement.java:105) @ org.apache.commons.dbcp.delegatingpreparedstatement.executeupdate(delegatingpreparedstatement.java:105) @ org.springframework.jdbc.core.jdbctemplate$2.doinpreparedstatement(jdbctemplate.java:916) @ org.springframework.jdbc.core.jdbctemplate$2.doinpreparedstatement(jdbctemplate.java:909) @ org.springframework.jdbc.core.jdbctemplate.execute(jdbctemplate.java:644) ... 29 more **caused by: java.sql.sqlexception: isam error: record locked.** @ com.informix.util.ifxerrmsg.getsqlexception(ifxerrmsg.java:407) @ com.informix.jdbc.ifxsqli.e(ifxsqli.java:3775)
i think , issue might specific informix database. following code might helpful
ifxxadatasource xadatasource=new ifxxadatasource(); xadatasource.setifxifx_lock_mode_wait(datasourceproperties.getlockwaittime()); xadatasource.setuser(datasourceproperties.getdbusername()); xadatasource.setpassword(datasourceproperties.getdbpassword()); xadatasource.setportnumber(datasourceproperties.getport()); xadatasource.setservername(datasourceproperties.getservername()); xadatasource.setifxpath(datasourceproperties.getdburl()); xadatasource.setifxifxhost(datasourceproperties.gethost()); xadatasource.setdatabasename(datasourceproperties.getdatabasename()); org.apache.tomcat.jdbc.pool.datasource datasourcelocal =new org.apache.tomcat.jdbc.pool.datasource(); datasourcelocal.setdatasource(xadatasource); datasourcelocal.setmaxactive(datasourceproperties.getmaxactive()); datasourcelocal.setinitialsize(datasourceproperties.getinitialsize()); datasourcelocal.settestonborrow(datasourceproperties.gettestonborrow());
you need add lock_mode_wait setting in ifxxadatasource data source object
Comments
Post a Comment