Update: the problem was the S3 configuration. The process was so long that the S3 at certain point cut the connection and the process threw an error. Changing the S3 configuration solved the problem.