Uploaded image for project: 'Moodle'
  1. Moodle
  2. MDL-69599

Forum Adhoc Task Failures



    • Type: Bug
    • Status: Open
    • Priority: Minor
    • Resolution: Unresolved
    • Affects Version/s: 3.8.4
    • Fix Version/s: None
    • Component/s: Forum, Tasks
    • Affected Branches:



      Moodle 3.8.4+ Build 20200827

      PHP: 7.2.33

      MYSQL: 5.7.31

      We updated to 3.8.4+ over the weekend, I made a post here, https://moodle.org/mod/forum/discuss.php?d=409577

      I found that you can run adhoc tasks via cli and also output the queries being ran so I went ahead and ran it, there are some forum posts it is trying to update but fails, an example query from the refresh_forum_post_counts task,

      UPDATE mdl_forum_posts SET message = ?,wordcount = ?,charcount = ? WHERE id=?
      [array (
        0 => '<p>This program is a grant funded city initiative geared at sport and nutrition lessons.  The program is a 25 week program for children involved with certain after school programs.  They spend 5 weeks developing skills on a sport and then have tournaments for that sport.  During that time, they are also providing weekly nutrition classes with different topics.  The children are pulled during their after school program so that it does not interfere with a parents schedule.  Also, since it is grant funded, it is free to children who want to participate and parents who agree to get them to the school so that they can be transported to the tournament locations. They do provide an exercise t-shirt, shorts,and a pair of athletic shoes as well.</p>
      <p>This program is building skills to help prevent childhood obesity.  The nutrition classes help teach them to make better nutrition choices so that they can avoid the ailments and problems that an unhealthy lifestyle can have. </p>
      <p>The nurse could offer a program packet to parents who are interested.  The nutrition classes will send home brochures and other literature about  making healthy food choices.</p>
      <p>The children will have something to look forward to since they will be exposed to different sports.  They can also keep active instead of playing video games or just being indoors.  They also get to sample certain healthy foods at the nutrition classes.</p>
      <p>This is overall an excellent program that the children can participate while being at an after school program.  </p>
      <p> </p>',
        1 => 251,
        2 => 1264,
        3 => '29234',
      ... used 2 dbqueries
      ... used 1.6989190578461 seconds
      Adhoc task failed: mod_forum\task\refresh_forum_post_counts,Error writing to database


      So this fails in Moodle, but when I ran the query manually in MySQL it updated successfully then the cron task was able to continue without error until it came across another, same issue, ran it manually in mysql and it updated and continued on, I fixed all the failed queries and now the task successfully completes each time its ran.

      I looked at the query, I don't see any reason why it would fail in Moodle trying to update database and then success when ran manually. Maybe you guys can figure it out





            Unassigned Unassigned
            jeverling Jason Everling
            Component watchers:
            Andrew Nicols, Jun Pataleta, Michael Hawkins, Shamim Rezaie, Simey Lameze, Amaia Anabitarte, Carlos Escobedo, Ferran Recio, Sara Arjona (@sarjona)
            0 Vote for this issue
            5 Start watching this issue