Spring batch Spring批处理-导致可能的死锁
我有一个包含多个步骤的批处理作业。每一步包括从5-6个连接的表中读取数据,然后写入我的报告表。 在步骤8中,在读写了大约450000条记录之后,它失败了,出现了异常-,原因是:java.sql.SQLException:无法进行索引读取以获取下一行。我知道此异常是由死锁引起的。没有其他步骤并行运行,这是写入报表的唯一步骤。是什么导致了这种僵局? 我在一个时间紧迫,以完成这项工作,任何帮助是非常感谢 我的工作结构是这样的Spring batch Spring批处理-导致可能的死锁,spring-batch,deadlock,Spring Batch,Deadlock,我有一个包含多个步骤的批处理作业。每一步包括从5-6个连接的表中读取数据,然后写入我的报告表。 在步骤8中,在读写了大约450000条记录之后,它失败了,出现了异常-,原因是:java.sql.SQLException:无法进行索引读取以获取下一行。我知道此异常是由死锁引起的。没有其他步骤并行运行,这是写入报表的唯一步骤。是什么导致了这种僵局? 我在一个时间紧迫,以完成这项工作,任何帮助是非常感谢 我的工作结构是这样的 步骤1 步骤2是一个拆分,其中[Step2a,Step2b]并行运行 步骤3
我的配置如下:
<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>
我认为,这个问题可能特定于informix数据库。下面的代码可能会有所帮助
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());
您需要在IfxXADataSource数据源对象中添加锁定模式等待设置您能提供配置吗?完整的堆栈跟踪?它实际上在哪一步失败了?我意识到,当我使用任务执行器(SimpleAsyncTaskExecutor)时,我遇到了这个死锁问题。何时建议使用异步任务执行器?
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());