How to handle dereuromark/cakephp-queue out of memory?

I am using the dereuromark/cakephp-queue plugin with only 1 worker, and every now and then, the worker stops responding until I use bin/cake queue worker end all and start a new worker. When I check the logs, I find these errors.

Is there any way to avoid this? How can I recover if this happens?

error_log

[12-Jun-2023 10:39:04 UTC] PHP Notice: fwrite(): write of 1192 bytes failed with errno=5 Input/output error in /home/feedlot/vendor/cakephp/cakephp/src/Console/ConsoleOutput.php on line 276

cli-error

2023-06-12 12:14:35 error: [Cake\Error\FatalErrorException] Fatal Error: Allowed memory size of 33554432 bytes exhausted (tried to allocate 12288 bytes) in /home/feedlot/vendor/cakephp/cakephp/src/Database/Statement/MysqlStatement.php on line 39

Stack Trace:

- /home/feedlot/vendor/cakephp/cakephp/src/Error/ExceptionTrap.php:283

- [internal]:??

cli-debug

2023-06-12 10:39:04 notice: fwrite(): write of 5 bytes failed with errno=5 Input/output error

Trace:

fwrite [internal], line ??

Cake\Console\ConsoleOutput::_write() /home/feedlot/vendor/cakephp/cakephp/src/Console/ConsoleOutput.php, line 276

Cake\Console\ConsoleOutput::write() /home/feedlot/vendor/cakephp/cakephp/src/Console/ConsoleOutput.php, line 203

Cake\Console\ConsoleIo::out() /home/feedlot/vendor/cakephp/cakephp/src/Console/ConsoleIo.php, line 201

Cake\Console\ConsoleIo::overwrite() /home/feedlot/vendor/cakephp/cakephp/src/Console/ConsoleIo.php, line 350

App\Command\FindNextErrorCommand::execute() /home/feedlot/src/Command/FindNextErrorCommand.php, line 64

Cake\Console\BaseCommand::run() /home/feedlot/vendor/cakephp/cakephp/src/Console/BaseCommand.php, line 189

Cake\Console\CommandRunner::runCommand() /home/feedlot/vendor/cakephp/cakephp/src/Console/CommandRunner.php, line 334

Cake\Console\CommandRunner::run() /home/feedlot/vendor/cakephp/cakephp/src/Console/CommandRunner.php, line 172

[main] /home/feedlot/bin/cake.php, line 12

bin/cake queue worker end all

2023-06-12 12:14:35 error: [Cake\Error\FatalErrorException] Fatal Error: Allowed memory size of 33554432 bytes exhausted (tried to allocate 12288 bytes) in /home/feedlot/vendor/cakephp/cakephp/src/Database/Statement/MysqlStatement.php on line 39

Stack Trace:

- /home/feedlot/vendor/cakephp/cakephp/src/Error/ExceptionTrap.php:283

- [internal]:??

[Cake\Error\FatalErrorException] Fatal Error: Allowed memory size of 33554432 bytes exhausted (tried to allocate 12288 bytes) in /home/feedlot/vendor/cakephp/cakephp/src/Database/Statement/MysqlStatement.php on line 39

Stack Trace:

#0 /home/feedlot/vendor/cakephp/cakephp/src/Error/ExceptionTrap.php(283): Cake\Error\ExceptionTrap->handleFatalError(1, 'Allowed memory ...', '/home/feed...', 39)

#1 [internal function]: Cake\Error\ExceptionTrap->handleShutdown()

#2 {main}
notice: fwrite(): write of 5 bytes failed with errno=5 Input/output error

is not related to this error because it happened at 2023-06-12 10:39:04 and not at 2023-06-12 12:14:35

So you can ignore those.

But in the end I can’t tell you why this happens to you because for me (and many other users) the plugin works fine.

All I can say is that I’d recommend you don’t let one worker run for longer periods of time but at least restart a worker every few hours.

1 Like