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

tag_cron() does not scale

    XMLWordPrintable

Details

    • MOODLE_28_STABLE
    • MOODLE_27_STABLE, MOODLE_28_STABLE
    • wip-MDL-48038-master
    • Hide

      To the tester I'm really sorry. This change involves a few new sql statements and will need to be tested on all supported databases.

      1. Load the test.php file into your moodle directory and run it.
      2. If you have a look at your tag_instance table you should see that you now have about 9000 entries.
      3. If you want to test this before using the patch, then make sure to comment out the following (tag/lib.php tag_delete_instance()):

        // Trigger tag removed event.
        $event = \core\event\tag_removed::create(array(
            'objectid' => $taginstance->id,
            'contextid' => $taginstance->contextid,
            'other' => array(
                'tagid' => $tag->id,
                'tagname' => $tag->name,
                'tagrawname' => $tag->rawname,
                'itemid' => $taginstance->itemid,
                'itemtype' => $taginstance->itemtype
            )
        ));
        $event->add_record_snapshot('tag_instance', $taginstance);
        $event->trigger();
        

        This code will fail if the tag name and tag rawname are not provided, which can not be provided when the tag has already been deleted. This is part of the code that we are testing. This is fixed in the patch.

      4. Run the following cron task: php admin/tool/task/cli/schedule_task.php --execute=\\core\\task
        tag_cron_task
      5. Note that the used dbqueries amount is around 220 (if you have around 9000 tag_instance entries) which is reduced from the previous figure of around 46000.
      Show
      To the tester I'm really sorry. This change involves a few new sql statements and will need to be tested on all supported databases. Load the test.php file into your moodle directory and run it. If you have a look at your tag_instance table you should see that you now have about 9000 entries. If you want to test this before using the patch, then make sure to comment out the following (tag/lib.php tag_delete_instance()): // Trigger tag removed event. $event = \core\event\tag_removed::create(array( 'objectid' => $taginstance->id, 'contextid' => $taginstance->contextid, 'other' => array( 'tagid' => $tag->id, 'tagname' => $tag->name, 'tagrawname' => $tag->rawname, 'itemid' => $taginstance->itemid, 'itemtype' => $taginstance->itemtype ) )); $event->add_record_snapshot('tag_instance', $taginstance); $event->trigger(); This code will fail if the tag name and tag rawname are not provided, which can not be provided when the tag has already been deleted. This is part of the code that we are testing. This is fixed in the patch. Run the following cron task: php admin/tool/task/cli/schedule_task.php --execute=\\core\\task tag_cron_task Note that the used dbqueries amount is around 220 (if you have around 9000 tag_instance entries) which is reduced from the previous figure of around 46000.
    • Team A Sprint 1, Team '; drop tables Sprint 2
    • Medium

    Description

      From moodle.org:

      php html/admin/tool/task/cli/schedule_task.php --execute=\\core\\task\\tag_cron_task
      Scheduled task: Background processing for tags
      ... used 125562 dbqueries
      ... used 56.182971954346 seconds
      Task completed.
      

      There looks to be something like a query per user from brief look with sql debugging.

      --------------------------------
      Query took: 6.8902969360352E-5 seconds.
      --------------------------------
      --------------------------------
      SELECT 'x' FROM tag WHERE id = ? LIMIT 0, 1
      [array (
        0 => '1',
      )]
      --------------------------------
      Query took: 7.2956085205078E-5 seconds.
      --------------------------------
      --------------------------------
      SELECT 'x' FROM user WHERE id = ? AND deleted = ? LIMIT 0, 1
      [array (
        0 => '330246',
        1 => 1,
      )]
      --------------------------------
      Query took: 6.8902969360352E-5 seconds.
      --------------------------------
      --------------------------------
      SELECT 'x' FROM tag WHERE id = ? LIMIT 0, 1
      [array (
        0 => '43',
      )]
      --------------------------------
      Query took: 7.2002410888672E-5 seconds.
      --------------------------------
      --------------------------------
      SELECT 'x' FROM user WHERE id = ? AND deleted = ? LIMIT 0, 1
      [array (
        0 => '330246',
        1 => 1,
      )]
      
      

      Attachments

        Issue Links

          Activity

            People

              abgreeve Adrian Greeve
              poltawski Dan Poltawski
              Simey Lameze Simey Lameze
              David Monllaó David Monllaó
              Rajesh Taneja Rajesh Taneja
              Matteo Scaramuccia, David Woloszyn, Huong Nguyen, Jake Dallimore, Michael Hawkins, Stevani Andolo, David Woloszyn, Huong Nguyen, Jake Dallimore, Michael Hawkins, Stevani Andolo
              Votes:
              0 Vote for this issue
              Watchers:
              6 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:
                9/Mar/15