-
Notifications
You must be signed in to change notification settings - Fork 11.8k
Referencing $this within batch callback depletes memory #38573
Copy link
Copy link
Closed
Description
- Laravel Version: 8.56.0
- PHP Version: 7.4.21
- Database Driver & Version: mysql 5.7.32
Description:
When running a batch set of jobs and one of the callbacks (then, catch or finally) calls $this php runs out of memory.
My guess is there's some sort of recursive serialisation happening.
Steps To Reproduce:
I was able to recreate it outside of discovering the issue using the following code:
\Log::debug('Attempt batch');
\Bus::batch([
[
// chain these
new JobA(),
new JobB(),
]
])->then(function() {
\Log::debug('Then callback after Job Batch succeeded');
$this->attempts(); // comment this out and it runs fine
})->catch(function (Batch $batch, \Throwable $exception) {
\Log::debug('Catch callback after Job Batch failed');
})->finally(function () {
\Log::debug('Finally callback after Job Batch ran');
})->name('Example Batch')->dispatch();
\Log::debug('Completed batch');Each of the jobs would just sleep(20).
With $this->attempts() left in the code will execute the \Log::debug('Attempt batch'); line and then crash. Commenting out $this->attempts() and everything runs as expected.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels
Type
Fields
Give feedbackNo fields configured for issues without a type.