I have an step configuration as follow:
stepBuilderFactory.get("step-migracion-documentos-sin-procesar")
.<ContenidoDocPendienteVW, ContenidoDocMigrado>chunk(1).reader(contenidoDocPendientesJdbcReader)
.processor(migrarContenidoDocPendientesProcessor)
.writer(classifierContenidoDocMigradoCompositeItemWriter).faultTolerant()
.retryPolicy(new SimpleRetryPolicy(3,getSupportedRetryExceptions()))
.backOffPolicy(getRetryBackoffPolicy())
.listener(jobMigracionRetryListener)
.listener(stepCompletedListener)
.build();
I launch the step reader for 100.000 records with pageSize of 1000. When the step arrives has processed about 89500 records the batch fails and stops it throwing the below error:
Encountered an error executing step step-migracion-documentos-sin-procesar in job job-migracion-documentos
java.lang.OutOfMemoryError: Java heap space
The next jobExecution in the next day, the batch starts but before itemReader starts the follow exception is thrown, and the batch ends without processing any record:
org.springframework.retry.RetryException: Non-skippable exception in recoverer while processing; nested exception is java.lang.OutOfMemoryError: Java heap space
at org.springframework.batch.core.step.item.FaultTolerantChunkProcessor$2.recover(FaultTolerantChunkProcessor.java:282)
at org.springframework.retry.support.RetryTemplate.handleRetryExhausted(RetryTemplate.java:512)
at org.springframework.retry.support.RetryTemplate.doExecute(RetryTemplate.java:351)
at org.springframework.retry.support.RetryTemplate.execute(RetryTemplate.java:211)
at org.springframework.batch.core.step.item.BatchRetryTemplate.execute(BatchRetryTemplate.java:217)
at org.springframework.batch.core.step.item.FaultTolerantChunkProcessor.transform(FaultTolerantChunkProcessor.java:291)
at org.springframework.batch.core.step.item.SimpleChunkProcessor.process(SimpleChunkProcessor.java:192)
at org.springframework.batch.core.step.item.ChunkOrientedTasklet.execute(ChunkOrientedTasklet.java:75)
at org.springframework.batch.core.step.tasklet.TaskletStep$ChunkTransactionCallback.doInTransaction(TaskletStep.java:406)
at org.springframework.batch.core.step.tasklet.TaskletStep$ChunkTransactionCallback.doInTransaction(TaskletStep.java:330)
at org.springframework.transaction.support.TransactionTemplate.execute(TransactionTemplate.java:133)
at org.springframework.batch.core.step.tasklet.TaskletStep$2.doInChunkContext(TaskletStep.java:272)
at org.springframework.batch.core.scope.context.StepContextRepeatCallback.doInIteration(StepContextRepeatCallback.java:81)
at org.springframework.batch.repeat.support.RepeatTemplate.getNextResult(RepeatTemplate.java:374)
at org.springframework.batch.repeat.support.RepeatTemplate.executeInternal(RepeatTemplate.java:215)
at org.springframework.batch.repeat.support.RepeatTemplate.iterate(RepeatTemplate.java:144)
at org.springframework.batch.core.step.tasklet.TaskletStep.doExecute(TaskletStep.java:257)
at org.springframework.batch.core.step.AbstractStep.execute(AbstractStep.java:200)
at org.springframework.batch.core.job.SimpleStepHandler.handleStep(SimpleStepHandler.java:148)
at org.springframework.batch.core.job.AbstractJob.handleStep(AbstractJob.java:392)
at org.springframework.batch.core.job.SimpleJob.doExecute(SimpleJob.java:135)
at org.springframework.batch.core.job.AbstractJob.execute(AbstractJob.java:306)
at org.springframework.batch.core.launch.support.SimpleJobLauncher$1.run(SimpleJobLauncher.java:135)
at org.springframework.core.task.SyncTaskExecutor.execute(SyncTaskExecutor.java:50)
at org.springframework.batch.core.launch.support.SimpleJobLauncher.run(SimpleJobLauncher.java:128)
at es.gva.melva.batch.migracion.config.SchedulerJobMigracion.runJob(SchedulerJobMigracion.java:42)
at es.gva.melva.batch.migracion.config.SchedulerJobMigracion.runBatchJob(SchedulerJobMigracion.java:60)
at es.gva.melva.batch.migracion.config.SchedulerJobMigracion.executeInternal(SchedulerJobMigracion.java:66)
at org.springframework.scheduling.quartz.QuartzJobBean.execute(QuartzJobBean.java:75)
at org.quartz.core.JobRunShell.run(JobRunShell.java:202)
at org.quartz.simpl.SimpleThreadPool$WorkerThread.run(SimpleThreadPool.java:573)
Caused by: java.lang.OutOfMemoryError: Java heap space
What is the reason behind this behavior ?
What should I do to resolve this ?
Thanks for reading!