Closed spring-projects-issues closed 10 years ago
Giovanni Dall'Oglio Risso commented
I'm sorry, I attached thwice the screenshot. Can somebody remove the duplication? Thanks
Michael Minella commented
Are you using iBatis or MyBatis? We don't support any version of MyBatis since it switched. If you want to use MyBatis (post fork), you should be using the ItemWriter
they provide.
Giovanni Dall'Oglio Risso opened BATCH-1873 and commented
We found a problem in a chunk with retry enabled.
We use MyBatis as writer
We had production problems:
We build a test case showing the problem (please: find attached).
Background: we have a table with not-nullable columns, and we have a job, with a chunk that
In this test case, we tested 4 scenarios (= 4 delegates)
JdbcBatchItemWriter
-> works fineSingleUpdateItemWriter
(the "for each item / write single item" approach, using JdbcTemplate) -> works fineMyBatisBatchItemWriter
(the JdbcBatchItemWriter for MyBatis, provided by MyBatis guys) -> works fineMybatisItemWriter
(the "for each item / write single item" using MyBatis) -> the broken oneIt seems to me, that the three working scenarios shares the "write immediatly" approach: the error is detected while in
write(List l)
method, so the retry template is able to intercept the error, and manage it.The failing one, defer the real write at the
TX.commit()
time, that is too late for being managed.To better explain the idea, i attached the screenshot of my stack, i see:
The first-level repeat explains why SB continues with the other chunks.
A simple solution could be to have a "simulated restart of a failed job", so the itemstreams reposition the elaboration, and everything can be continued, but this way you loose the optimizations (the internal readed-items list).
In our case, we work-arounded the problem adopting the
MyBatisBatchItemWriter
, but i'm writing this issue because you can choose to investigate this problem: deferred write could be a common scenario (I remember something like that in theFlatFileItemWriter
, that is ways more impacting)Affects: 2.1.8
Attachments: