Have gone through with lot of internet findings and other sources, but could not find any good reason why spring batch transaction works on step level rather than job level in a multi-steps job.
Even if a step is considered as a domain ,independent unit of the job as per documentation but still it is a part of a job (task) that need to be done.
Let say a job needs to read a excel file (with 2 sheets ,each having 6 millions of rows).
I would say reading of each sheet has been broken in a form of step. each sheet has its own style of processing of rows and writing(Database).
Processing of any sheet is NOT having any relation to other sheet.These are independent unit. But overall processing of any sheet is sub-task of job.
And processing of a file should be considered FAILURE if there is any problem in any sheet and it should roll back any data written so far.
But because reading sheet has been in form of step and if a sheet has been processed successfully it won't be roll backed in case of failure noticed in next sheet.
I would dis-agree to merge both steps in a single one just for the sake of solution.
Why spring batch doesn't provide any option to roll back all steps in failure of a job(task)?
I don't want to forward data from one step to another (write once only to database) as that is not related data at all as I said earlier and that is huge too (6 million) rows for a very longer time of frame in memory.