Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ad-hoc task fails #18

Open
cborn opened this issue Aug 17, 2022 · 7 comments
Open

ad-hoc task fails #18

cborn opened this issue Aug 17, 2022 · 7 comments

Comments

@cborn
Copy link

cborn commented Aug 17, 2022

Moodle 3.11.8
`
Execute adhoc task: tool_deletecourses\task\delete_courses_task
... started 14:35:07. Current memory use 28.2MB.
... used 160 dbqueries
... used 2.2654910087585 seconds
Adhoc task failed: tool_deletecourses\task\delete_courses_task,Coding error detected, it must be fixed by a programmer: A lock was created but not released at:
/var/www/moodle/releases/20220811171319Z/admin/tool/deletecourses/classes/task/delete_courses_task.php on line 109

Code should look like:

$factory = \core\lock\lock_config::get_lock_factory('type');
$lock = $factory->get_lock(cf96af778e845cf02aae535c741c3dd75f883f05);
$lock->release(); // Locks must ALWAYS be released like this.

Backtrace:

  • line 75 of /admin/tool/deletecourses/classes/task/delete_courses_task.php: call to core\lock\lock->__destruct()
  • line 341 of /lib/cronlib.php: call to tool_deletecourses\task\delete_courses_task->execute()
  • line 198 of /lib/cronlib.php: call to cron_run_inner_adhoc_task()
  • line 76 of /lib/cronlib.php: call to cron_run_adhoc_tasks()
  • line 178 of /admin/cli/cron.php: call to cron_run()'
@alyfilipe
Copy link

alyfilipe commented Jun 16, 2023

Some Problem:

Execute adhoc task: tool_deletecourses\task\delete_courses_task
Adhoc task id: 11215547
Adhoc task custom data: {"category":682,"recursive":"1","disablerecyclebin":"1"}
... started 12:43:09. Current memory use 106.9 Mb.
Debugging increased temporarily due to faildelay of 3840
... used 195 dbqueries
... used 2.8747470378876 seconds
Adhoc task failed: tool_deletecourses\task\delete_courses_task,Erro de codificação detectado e deve ser corrigido por um programador: A lock was created but not released at:
/opt/moodle/moodle/admin/tool/deletecourses/classes/task/delete_courses_task.php on line 109

Code should look like:

$factory = \core\lock\lock_config::get_lock_factory('type');
$lock = $factory->get_lock(223196997);
$lock->release(); // Locks must ALWAYS be released like this.

Backtrace:

  • line 75 of /admin/tool/deletecourses/classes/task/delete_courses_task.php: call to core\lock\lock->__destruct()
  • line 359 of /lib/cronlib.php: call to tool_deletecourses\task\delete_courses_task->execute()
  • line 198 of /lib/cronlib.php: call to cron_run_inner_adhoc_task()
  • line 131 of /admin/cli/adhoc_task.php: call to cron_run_adhoc_tasks()

@mackensen
Copy link
Contributor

What version of the plugin and what version of Moodle?

@alyfilipe
Copy link

Moodle: 4.1.1+
plugin 3.9

@drfyzziks
Copy link

Seeing the same on a Moodle instance I look after.

Moodle 3.9.17 (build: 20220912)
Plugin: v3.9.0 (2022041200)

I found the following in the task logs. But PHP's error log doesn't show anything obviously related.

Execute adhoc task: tool_deletecourses\task\delete_courses_task
... started 10:08:04. Current memory use 64.7MB.
... used 696 dbqueries
... used 0.33661603927612 seconds
Adhoc task failed: tool_deletecourses\task\delete_courses_task,Coding error detected, it must be fixed by a programmer: A lock was created but not released at:
/data/moodle/admin/tool/deletecourses/classes/task/delete_courses_task.php on line 109

 Code should look like:

 $factory = \core\lock\lock_config::get_lock_factory('type');
 $lock = $factory->get_lock(a556ff9e35d7dfa4e9a71c372e887bdf196460e2);
 $lock->release();  // Locks must ALWAYS be released like this.

A moodle admin was using the tool to delete a large number of courses. It ran fine a week ago and took 11 hours & 11 minutes to delete a large # of courses. He ran it again, 5 days later, and it ran for 18 minutes before encountering the lock error.

All subsequent runs of the tool fail in less than a second, with the same lock error. So it seems like there's a lock hanging around somewhere that needs to be cleaned up.

@mackensen
Copy link
Contributor

It sounds to me like there's something about that particular course that causes the plugin to fail. Let me think about how to throw a better debugging message.

@mackensen
Copy link
Contributor

I'm wondering if it's related to this core issue: https://tracker.moodle.org/browse/MDL-77924.

@mackensen
Copy link
Contributor

Testing confirms that some, not all, activity modules are affected by MDL-77924 and that this plugin will fail if those plugins are present in a course and disabled. That's not necessarily the problem folks are encountering here, but it is definitely a scenario that produces this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants