The root cause here is java.lang.OutOfMemoryError: Java heap space
To resolve this, either decrease your batch size, in this case, lower 500. Or add more java heap memory to your app. Depending on where the app is running:
In my opinion it’s not the best solution to increase memory.
If you want to clear a database table of 13 million records, you can also use a more low level database solution.
For example, the native SQL script below I use for clearing a table with millions of records in < 1 second:
CREATE TABLE new_integration_run_logs LIKE integration_run_logs;
RENAME TABLE integration_run_logs TO old_integration_run_logs, new_integration_run_logs TO integration_run_logs;
DROP TABLE old_integration_run_logs;