Force run adhoc task

Re: Force run adhoc task

by Christos Savva -
Number of replies: 13
Hi Andrew

Thank you so much for your reply.

I will describe below what I found so far, and please correct me if I got something wrong

I have checked the codein file

/moodle/mod/forum/classes/task/send_user_digests.php

There I found that a function empty_queue which I guess is suppose to clear the queue as soon as the digest goes out to the user.

Then I went to the DB and checked the table mdl_forum_queue sorted by timemodified, it seems that the queue is there from 05/03/2020, 5 days ago.


Then I went to table mdl_task_adhoc and run the following query

SELECT *, FROM_UNIXTIME(nextruntime )
FROM mdl_task_adhoc mta
WHERE userid = 177;

I got this result

So it seems that user_digests for the specific user will be sent out today.

Logs report that everything was successfull.

So now my questions are:
1. When the adhoc task is run, it should execute all rows in the mdl_forum_queue table? If yes, this is not happening for me
2. Is there a limit on how many queue tasks will be ran? If yes, can I change the value? Note that there are 1496 records for user 177 in mdl_forum_queue table
3. If I manually delete records from mdl_forum_queue tabl, will I cause any issues?

Sorry for the long post, am trying to be as specific as possible smile


In reply to Christos Savva

Re: Force run adhoc task

by Marie-Eve Lévesque -
Picture of Core developers Picture of Plugin developers
Hi Christos,

We are having a similar problem, with ad hoc tasks for \mod_forum\task\send_user_digests and \mod_forum\task\send_user_notifications. The mdl_forum_queue is also full of entries.

  • Did you find what was causing the problem?
  • What was your solution?
In reply to Marie-Eve Lévesque

Re: Force run adhoc task

by Christos Savva -
Hi Marie,

I am still not sure what caused the problem, but to resolve it I manually changed the nextruntime in the mdl_adhoc_task table to the closest time possible.

ie now is 2020-10-16T10:42, i updated the nextruntime to run 2020-10-16T10:45

converted the date into timestamp and run the cron manually until the queue was empty.

After that everything returned to normal
Average of ratings: Useful (3)
In reply to Christos Savva

Re: Force run adhoc task

by Marie-Eve Lévesque -
Picture of Core developers Picture of Plugin developers

Ok, thanks!

On our side, we had so much entries in the task table (300 000) so we ended up deleting entries in the mdl_adhoc_task and mdl_forum_queue tables (losing notifications). But your solution might be useful if the problem occurs again!

Thanks!

Marie-Eve

In reply to Marie-Eve Lévesque

Re: Force run adhoc task

by Osvaldo Canato -
Hello, Marie-Eve!

I have a similar problem here and I'm thinking of applying your procedure, excluding some entries in mdl_task_adhoc, especially the entries for course_delete_modules.

So my question is what am I going to lose doing this.

You said you missed notifications, but I think this is related to the send_user_notification entries.

What about course_delete_modules entries? Can you tell what happens when they are deleted?

Thanks in advance!

Osvaldo
In reply to Osvaldo Canato

Re: Force run adhoc task

by Christos Savva -
I dont this would be a good idea.

I think the task you are referring is deleting related data of course modules that you have deleted from courses.

For example db entries or files

I think you should not skip those tasks.
In reply to Christos Savva

Re: Force run adhoc task

by Osvaldo Canato -
Thanks for the reply!

The problem is that all tasks (around 20,000) were stucked waiting for those problematic tasks to run.

And I purged caches, looked for error in moodledata/temp/backup/ ... no problem found nowhere.

The only way I could imagine to go on was excluding or postpone the stucked entries.

So, at least for now I decided to postpone and once that was done, tasks finally started to run.

Now I will have to decide what to do with the 26 blocked entries. It is curious: they are all related to 2 courses by the same teacher. It seems that there is a problem with some files that he tried repeatedly to put into activities.

The fact is that these entries seem impossible to perform. Every time they run (by comandline), results in a "PHP Fatal error: Allowed memory size of 4294967296 bytes exhausted". But I have already tried to increase the memory limit even to 7GB per config.php ($CFG->extramemorylimit = '7168;) and it seems that the query only wastes more time, killing when the memory runs out.
In reply to Osvaldo Canato

Re: Force run adhoc task

by Christos Savva -

What is the value you have for memory_limit in your php.ini?

In reply to Christos Savva

Re: Force run adhoc task

by Osvaldo Canato -
It's 256 MB, but it doesn't seem to be related to the problem.

Maybe output_buffering, yes, as it is set to 4096M.

But, the fact is that I can get around what is defined in php.ini using $ CFG-> extramemorylimit" in moodle config.php. So I did that, leaving 7GB for tasks and, after waiting a long time, the result is "" Fatal PHP error: allowed memory size of 7516192768 bytes exhausted "!

That's it!
In reply to Osvaldo Canato

Re: Force run adhoc task

by Manfred Steger -
Hi, thanks a lot to all for the hints to get rid off the problem with the failing ad hoc task. After reading serveral hours through different posts, my solution was disabling the recycle bin in the moodle backend. After that I used the web cron and it works like a charm! Before then the cron stopped always by the ad hoc task: \core_course\task\course_delete_modules. It doesn't matter whether all modul plugins turned off.

There are two big problems if the cron failed at this point:

  • no forum post messages were sent
  • setup for grades have orphan entries and there is a warning message something like "deletion in progress". Grades are unusable at this point if you delete a activity.
If you encounter one of those problems, maybe it's the failing cron job. This issue costs me several days of work, maybe not that time assuming for a developer but i am a teacher.

Cron script completed correctly
Cron completed at 07:26:50. Memory used 4.9MB.
Execution took 0.15051 seconds


Average of ratings: Useful (1)
In reply to Manfred Steger

Re: Force run adhoc task

by Dr. Nellie Deutsch -
Where did you disable the recycle bin exactly?
In reply to Dr. Nellie Deutsch

Re: Force run adhoc task

by Dr. Nellie Deutsch -

mdl_task_adhoc are failing

In reply to Dr. Nellie Deutsch

Re: Force run adhoc task

by Ken Task -
Picture of Particularly helpful Moodlers

@Dr. Nellie ...

PIggy-backed (even if related) reporting of an issue isn't a good idea.   IF true, suggest posting a new thread with description of your problem/issues.  Proposed Subject line? "mdl_task_adhoc are failing" then provide some details as well as server info - mdl version, etc.

Your problems deserve focused attention of those who might respond.

2 cents ...

'SoS', Ken


In reply to Christos Savva

Re: Force run adhoc task

by Gabriel JALAM -
Hello,
To update the nextruntime i use this sql code:
begin; update mdl_task_adhoc set nextruntime = unix_timestamp()+60; commit;
Average of ratings: Useful (1)