Giter VIP home page Giter VIP logo

tool_adhocbug's Introduction

Description

Some ad-hoc tasks fail with Class not found fatal error when they are started from the cli/adhoc_task.php --keep-alive=59, but run normally and succeed when run from the "normal" cli/cron.php.

A specific example implemented in this plugin, the get_moduleinfo_data() function triggers this behavior.

Steps to reproduce

  1. Install this plugin in your test Moodle.
  2. Create at least one course with at least one course module.
  3. Add the * * * * * /usr/bin/php /path/to/moodle/admin/cli/adhoc_task.php --execute --keep-alive=59 to your crontab, and log its output somewhere.
  4. Navigate to the http://your.test.moodle/admin/tool/adhocbug/index.php page and click the "Run task" button.
  5. Look at the cron output and see that it's failing with Class "grade_item" not found error.
  6. Disable the "keep-alive" cron runner, and next time the task is retried it will succeed.

For Moodle 4.2 or higher

In Moodle 4.2 the default cron script has this "keep-alive" behavior enabled by default. (See: https://tracker.moodle.org/browse/MDL-77186). So, to reproduce this bug, you don't need the additional cli/adhoc_task.php ... in your crontab.

So, in the above list:

  • skip #3.
  • Observe the task failing.
  • Change the default crontab line to: .../admin/cli/cron.php --no-keep-alive >> log_somewhere 2>&1.
  • Wait until the "keep-aliving" instances exit (or kill them).
  • The next time the ad-hoc task is retried it will succeed.

Note that this buggy behavior doesn't always happen with this setup (regular cron with "keep-alive" enabled by default). I was able to reproduce it a few times, but not reliably. The cli/adhoc_task.php --execute --keep-alive=59 always triggers this bug, even in Moodle 4.2.

Notes

Most of the regular ad-hoc tasks run just fine when started from "keep-alive" cron jobs. It's one obscure plugin where we noticed this behavior. But it makes the bug that much more devious, as it's not clear that the problem is not with the plugin, but with how the task is run.

I have tested this with the latest 4.1 and 4.2 Moodle versions.

Hat tip to @olivabigyo who discovered the bug!

tool_adhocbug's People

Contributors

klao avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.