I discovered that we have in our Moodle instance some users that have comunicated some email and nowadays, these email addresses do not exist.
This is making the task \mod_forum\task\send_user_notifications try and try and try to send emails to these people, without exit, since email addresses do not exist any more.
And this may happen to other adhoc tasks too, for other reasons.
I know that I could delete the records of the table task_adhoc for those users and finish with the issue.
However, I think this is only a temporary patch. If any other message is sent to those users or any other Moodle user enters to the same situation, we will face the same issue again.
After commenting it within our team, we believe that it would be interesting to have some setting (preferably on the web, but also acceptable only via config.php) to let adhoc tasks in general, or to only some specific adhoc task, to run for a maximum of X time (for instance, 5 days).
Nowadays, technology may fail, but it is not expected to fail during so long time. And if locally or for any reason, there is some trouble with the Moodle instance, this setting could then be disabled, and let the adhoc task requeue until external problem is solved.
So, even though we started talking about forum module and one of its adhoc tasks, this issue is related to Moodle adhoc tasks in general. However, I would choose forum module just to start with the use case I found. Let us see if it is interesting in general.
Is this proposal sound for you for adhoc tasks in forum module? And, is it interesing this proposal aslo in general to any adhoc task?