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

Exceptions can be suppressed by improper lock release #127

Open
pennedav opened this issue Mar 18, 2020 · 0 comments
Open

Exceptions can be suppressed by improper lock release #127

pennedav opened this issue Mar 18, 2020 · 0 comments
Labels

Comments

@pennedav
Copy link
Contributor

I had a case where the crawler just seemed to get stuck. Turns out it was because of a dml_write_exception being thrown from within crawl() in classes/robot/crawler.php. In my case it was because there was a page having a link that was longer than 1033 characters (the size of the url field). (This alone needs to be submitted as a separate issue.) What was confounding to me was that I had to dig to find the actual dml_write_exception because all I was seeing in my cron logs (PHP error logs were silent) was:

Adhoc task failed: tool_crawler\task\adhoc_crawl_task,Coding error detected, it must be fixed by a programmer: A lock was created but not released at: /path/to/moodle/admin/tool/crawler/classes/robot/crawler.php on line 526

 Code should look like:

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

Wrapping the call to crawl() on line 541 in a try-catch-finally resolves this and you then actually see the error report in Moodle's cron output:

Execute adhoc task: tool_crawler\task\adhoc_crawl_task
... started 13:49:07. Current memory use 44.2MB.
... used 51 dbqueries
... used 0.75267791748047 seconds
Adhoc task failed: tool_crawler\task\adhoc_crawl_task,Error writing to database
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants