Results 1 to 2 of 2

Thread: DB Lock exception in multi threaded step execution

  1. #1
    Join Date
    Aug 2010
    Posts
    2

    Exclamation DB Lock exception in multi threaded step execution

    Hi,

    I am trying to do multi threaded step execution using '<batch:split>'.

    I am using the persistent job repository model as the in memory model doesn't support multi-threaded step execution.

    Following are the application context file entries.
    <bean id="dataSource" class="org.springframework.jdbc.datasource.DriverM anagerDataSource">
    <property name="driverClassName" value="com.mysql.jdbc.Driver" />
    <property name="url" value="jdbc:mysql://localhost/test" />
    <property name="username" value="root" />
    <property name="password" value="root" />
    </bean>

    <bean id="transactionManager"
    class="org.springframework.jdbc.datasource.DataSou rceTransactionManager">
    <property name="dataSource" ref="dataSource" />
    </bean>
    <batch:job-repository id="jobRepository" data-source="dataSource" transaction-manager="transactionManager" isolation-level-for-create="DEFAULT" table-prefix="BATCH_"/>

    ......................


    I am trying to read data from two different tables and writing to two other tables.


    following is the job declaration.

    <batch:job id="simpleJob" incrementer="sampleIncrementer" restartable="true">
    <batch:split id="split1" task-executor="taskExecutor">
    <batch:flow>
    <batch:step id="step2">
    <batch:tasklet transaction-manager="transactionManagerTwo">
    <batch:listeners>
    <batch:listener ref="itemFailureLoggerListener" />
    </batch:listeners>
    <batch:chunk reader="cursorReaderTwo" writer="myItemWriter2"
    commit-interval="2" />
    </batch:tasklet>
    </batch:step>
    </batch:flow>
    <batch:flow>
    <batch:step id="step1">
    <batch:tasklet>
    <batch:listeners>
    <batch:listener ref="itemFailureLoggerListener" />
    </batch:listeners>
    <batch:chunk reader="cursorReader" writer="myItemWriter1"
    commit-interval="4" />
    </batch:tasklet>
    </batch:step>
    </batch:flow>
    </batch:split>
    </batch:job>

    -----------------------------------------------
    I use mySql 5 as DB.
    Getting the following exception while trying to execute the batch job

    org.springframework.dao.CannotAcquireLockException : PreparedStatementCallback; SQL [INSERT into BATCH_STEP_EXECUTION(STEP_EXECUTION_ID, VERSION, STEP_NAME, JOB_EXECUTION_ID, START_TIME, END_TIME, STATUS, COMMIT_COUNT, READ_COUNT, FILTER_COUNT, WRITE_COUNT, EXIT_CODE, EXIT_MESSAGE, READ_SKIP_COUNT, WRITE_SKIP_COUNT, PROCESS_SKIP_COUNT, ROLLBACK_COUNT, LAST_UPDATED) values(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)]; Lock wait timeout exceeded; try restarting transaction; nested exception is java.sql.SQLException: Lock wait timeout exceeded; try restarting transaction

    Attached the context file and complete error log.
    Any help is greatly appreciated.
    Attached Files Attached Files

  2. #2
    Join Date
    Jun 2005
    Posts
    4,232

    Default

    The poster of this thread (http://forum.springsource.org/showth...sin terceptor) had this issue (amongst others) and solved it eventually with a combination of retry configuration in the step and job repository.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •