Issue Bug Closed

#67463Scheduler sometimes uses 100% CPU for days

Lienhart Woitok 06/15/15, 14:06 updated 10/19/17, 21:37

Description

On several servers I regularly notice PHP-CLI processes taking 100% CPU and accumulating several thousand CPU minutes. Today I debugged further and attached gdb to one of these processes and noticed it calling Scheduler->fetchTask in a loop. It was quite hard to really follow the execution flow of php, but as far as I figured it out it does the database query to look for a new task to execute, handles an exception and starts over. A possible path how this can lead to an endless loop is a mysql timeout (mysql has gone away), which results in a FALSE result from exec_SELECTquery, throwing an UnexpectedValueException, which is then handled in scheduler_cli_dispatch.php:68 with a continue call, starting the loop again.

It could easily be fixed by throwing an OutOfBoundsException (which stops the loop) instead of the UnexpectedValueException in case of an SQL error preventing the task fetching. Is there a specific reason why the execution should continue in this case? The exception was introduced by Mathias Schreiber, maybe he can say something about that?

Reviews 3