Results 1 to 2 of 2

Thread: Spring batch 2.1.2 multi-threaded step deadlock in ResultHolderResultQueue.java

  1. #1
    Join Date
    Nov 2007
    Posts
    5

    Default Spring batch 2.1.2 multi-threaded step deadlock in ResultHolderResultQueue.java

    We got deadlock while doing multithreading in a step (item reader "someReader" is synchronized, item writer "dummyWriter" really doesn't do anyting). We are using Spring batch 2.1.2. The application hangs in the middle (when the deadlock happens). Below is a simplified version of the batch step config:
    <step id="multiThreadedStep">
    <tasklet allow-start-if-complete="true" task-executor="taskExecutor"
    throttle-limit="21">
    <chunk reader="someReader" processor="someProcessor" writer="dummyWriter"
    commit-interval="1" skip-limit="500"
    >
    ...
    </chunk>
    </tasklet>
    </step>


    <beans:bean id="taskExecutor" class="org.springframework.scheduling.concurrent.T hreadPoolTaskExecutor">
    <beansroperty name="corePoolSize" value="20"/>
    <beansroperty name="maxPoolSize" value="22"/>
    <beansroperty name="queueCapacity" value="15"/>
    </beans:bean>


    Below is the thread dump that shows the deadlock:
    "SimpleAsyncTaskExecutor-1" prio=10 tid=0x00000000477f7000 nid=0x54d8 in Object.wait() [0x0000000046478000]
    java.lang.Thread.State: WAITING (on object monitor)
    at java.lang.Object.wait(Native Method)
    at java.lang.Object.wait(Object.java:485)
    at org.springframework.batch.repeat.support.ResultHol derResultQueue.take(ResultHolderResultQueue.java:1 34)
    - locked <0x00002aaacb97ded0> (a java.lang.Object)
    at org.springframework.batch.repeat.support.ResultHol derResultQueue.take(ResultHolderResultQueue.java:3 3)
    at org.springframework.batch.repeat.support.TaskExecu torRepeatTemplate.getNextResult(TaskExecutorRepeat Template.java:143)
    at org.springframework.batch.repeat.support.RepeatTem plate.executeInternal(RepeatTemplate.java:214)
    at org.springframework.batch.repeat.support.RepeatTem plate.iterate(RepeatTemplate.java:143)
    at org.springframework.batch.core.step.tasklet.Taskle tStep.doExecute(TaskletStep.java:247)
    at org.springframework.batch.core.step.AbstractStep.e xecute(AbstractStep.java:196)
    at org.springframework.batch.core.job.SimpleStepHandl er.handleStep(SimpleStepHandler.java:135)
    at org.springframework.batch.core.job.flow.JobFlowExe cutor.executeStep(JobFlowExecutor.java:61)
    at org.springframework.batch.core.job.flow.support.st ate.StepState.handle(StepState.java:60)
    at org.springframework.batch.core.job.flow.support.Si mpleFlow.resume(SimpleFlow.java:144)
    at org.springframework.batch.core.job.flow.support.Si mpleFlow.start(SimpleFlow.java:124)
    at org.springframework.batch.core.job.flow.FlowJob.do Execute(FlowJob.java:135)
    at org.springframework.batch.core.job.AbstractJob.exe cute(AbstractJob.java:281)
    at org.springframework.batch.core.launch.support.Simp leJobLauncher$1.run(SimpleJobLauncher.java:120)
    at java.lang.Thread.run(Thread.java:619)

    I searched Spring batch JIRA database and didn't see a bug for this. We are trying to repro. Is this a Spring batch bug? Or was it becuase of wrong batch configuration? Please help. Thanks a lot!

  2. #2
    Join Date
    May 2011
    Location
    New Delhi, India
    Posts
    157

    Default

    This is caused most probably by the synchronized reader. Can you remove synchronized & then re-run the test. Not getting the deadlock will confirm that synchronized reader is the problem.

Posting Permissions

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