How to handle commit failure after committing a number of records?