Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.Sign up
MultiResourceItemWriter - Job restart failing (File is not writable) if last file first chunk failed [BATCH-2759] #845
I'm developing an Spring Batch application that writes database rows in CSV files. The database is huge so I need to generate multiple output CSV files partitioned (outputfile.csv.1, outputfile.csv.2, outputfile.csv.3 .....)
I'm testing all data cases and I have found a problem when I restart the failed job in this situation. When the execution failed in the first chunk of a new partitioned file, this new file is not created (I tried shouldDeleteIfEmpty = false but the file is not created).
When I try the restart, it seems that is expecting this last missing partitioned failed file.
The execution fails an I can see in the ouput the generated files (outputfile.csv.1, outputfile.csv.2, outputfile.csv.3) with the 300 first rows (6 chunks and 3 completed files).
When I restart the job, I'm getting the exception:
org.springframework.batch.item.ItemStreamException: File is not writable: [XXXX...\outputfile.csv.4]
It seems that expects this file, but was not created due to the error in the first chunk (I tried shouldDeleteIfEmpty = false but the file is not created)
Reviewing the database repository I can check the execution, and the value of the resource index is 4
I tried configuring the FlatFileItemWriter flags with different values (AppendAllowed, ShouldDeleteIfEmpty, ShouldDeleteIfExists) but the same issue is thrown