Its probably easer to just restart with the input file again if the aggregation was not fully completed.
So during aggregation store in a temporary file. And then when fully done, then rename/move the file to its intended location.
thanks for your response.
I tried your solution, but sometimes I still have more data than required.
As you said, I store input files in a temporary directory just before they are splitted, and as soon as the aggregation is completed, I remove these files and put them into an history directory.
When an unexpected stop occurs, some files can be in this temporary directory because the aggregation is not complete. So, before the route starts again, I move these files into the input directory and sometimes I have more data at the end.
When you startup you should delete any temporary files, as they are not complete.