Announcement Announcement Module
Collapse
No announcement yet.
Parallel steps throw java.sql.SQLException: Cursor state not valid. Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Parallel steps throw java.sql.SQLException: Cursor state not valid.

    Hi again,

    Now I have a new problem, sadly...

    I had my job working, but I decided to make it better, to improve its performance by using parallel steps.

    So I have something like this

    Code:
        <batch:step id="abstract" abstract="true">
                <batch:tasklet>
                    <batch:chunk reader="as400SiniestroHolderTodayReader" />
                </batch:tasklet>
        </batch:step>
            
        <batch:job id="verificaSiniestroJobV2">
            
               <batch:step id="step11" parent="abstract" next="aStep">
                <batch:tasklet>
                    <batch:chunk processor="as400SiniestroFilterProcessor" />
                </batch:tasklet>
            </batch:step>
            
            <batch:step id="aStep" parent="step11"> 
                <batch:tasklet>
                    <batch:chunk writer="..." />
                </batch:tasklet>
                <batch:next on="COMPLETED" to="step12" />
            </batch:step>
               
            <batch:step id="step12" parent="step11" next="pParalelo">
                   <batch:tasklet>
                    <batch:chunk writer="..." />
                </batch:tasklet>
               </batch:step>
            
            <batch:split id="pParalelo" task-executor="taskExecutor">
    
    
                <batch:flow>
                    <batch:step id="step13" parent="abstract">
                        <batch:tasklet>
                            <batch:chunk
                                processor="..." writer="..."
                                commit-interval="100">
                            </batch:chunk>
                        </batch:tasklet>
                    </batch:step>
                </batch:flow>
                
                <batch:flow>
                    <batch:step id="step14" parent="abstract">
                        <batch:tasklet>
                            <batch:chunk
                                processor="...." writer="..."
                                commit-interval="100">
                            </batch:chunk>
                        </batch:tasklet>
                    </batch:step>
                </batch:flow>
                
                <batch:flow>
                    <batch:step id="step15" parent="abstract">
                        <batch:tasklet>
                            <batch:chunk
                                processor="..." writer="..."
                                commit-interval="100">
                            </batch:chunk>
                        </batch:tasklet>
                    </batch:step>
                </batch:flow>
                
                <batch:flow>
                    <batch:step id="step16" parent="abstract">
                        <batch:tasklet>
                            <batch:chunk
                                processor="..." writer="..." commit-interval="100">
                            </batch:chunk>
                        </batch:tasklet>
                    </batch:step>
                </batch:flow>
                
            </batch:split>
            
        </batch:job>
    
        <bean id="taskExecutor" 
            class="org.springframework.core.task.SimpleAsyncTaskExecutor"/>

    The first job I had it was like this .

    Code:
    abstract step -> processor  (parent abstract) -> writer (parent abstract) -> writer (parent abstract) -> processor and writer (parent abstract) -> processor and writer (parent abstract) -> processor and writer (parent abstract) -> processor and writer (parent abstract)
    This actually works, but the last 4 steps don't depend on the previous step (the 4th step doesn't depend on the 3rd, the 3rd on the 2nd, and the 2nd on the 1st), so I decided that it would be much better if I run those jobs in parallel, since they depend on the abstract parent, the reader.

    And I want it like this, doing it as a parallel step :

    Code:
    abstract step -> processor  (parent abstract) -> writer (parent abstract) -> writer (parent abstract) -> [parallel] { processor and writer (parent abstract), processor and writer (parent abstract), processor and writer (parent abstract), processor and writer (parent abstract) } [/parallel]
    If I run the job in parallel it throws this message :

    Code:
    org.springframework.batch.core.step.AbstractStep execute Encountered an error executing the step
                                     org.springframework.jdbc.UncategorizedSQLException: Attempt to process next row failed; uncategorized SQLException for SQL [SELECT REMOVED FOR BREVITY]; SQL state [24000]; error code [-99999]; Cursor state not valid.; nested exception is java.sql.SQLException: Cursor state not valid.
    The reader should return the resultset only once, and the processor and writers should be using that data, but is like it's trying to execute the same SELECT for every step in the parallel step, but if I run the job that runs every step sequencially it works like a charm.

    I don't know what it could be, I tried what I found on the Spring in action book, and at first it looks like it should work, but it failed... The reader reads from AS400 database.

    Any help would be awesome.

    Thanks in advance.
Working...
X