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

Make my_reset_page_for_all_users for dashboards more robust

    XMLWordPrintable

    Details

    • Testing Instructions:
      Hide

      1)  Download the attached test script 'test.php' and drop it in the webroot of the moodle installation. This script will generate 10,000 users and create custom dashboards for all these users for testing.

      2) Run the script from a terminal in the webroot. This will take around 5 mins to create all the testing data.

      php test.php

      3) Open a database shell and run the following statement and verify the result is ~10000 (Exact number is not important).

      SELECT COUNT(*) FROM mdl_my_pages;

      4) Visit /my/indexsys.php and click 'Reset dashboard for all users'

      5) Confirm that a progress bar is visible, which updates every 5-15s (depending on CPU speed).

      6) Verify that upon completion, a continue button is visible, and a message banner for success appears.

      7) Confirm clicking the button takes you back to the indexsys.php page.

      8) In the DB shell, run the  same SELECT again and confirm the value is ~10,000 smaller (there may be other pages not touched in this table).

      Show
      1)   Download the attached test script 'test.php' and drop it in the webroot of the moodle installation. This script will generate 10,000 users and create custom dashboards for all these users for testing. 2) Run the script from a terminal in the webroot. This will take around 5 mins to create all the testing data. php test.php 3) Open a database shell and run the following statement and verify the result is ~10000 (Exact number is not important). SELECT COUNT(*) FROM mdl_my_pages; 4) Visit /my/indexsys.php and click 'Reset dashboard for all users' 5) Confirm that a progress bar is visible, which updates every 5-15s (depending on CPU speed). 6) Verify that upon completion, a continue button is visible, and a message banner for success appears. 7) Confirm clicking the button takes you back to the indexsys.php page. 8) In the DB shell, run the  same SELECT again and confirm the value is ~10,000 smaller (there may be other pages not touched in this table).
    • Affected Branches:
      MOODLE_311_STABLE, MOODLE_39_STABLE
    • Fixed Branches:
      MOODLE_311_STABLE
    • Pull 3.11 Branch:
      MDL-70444-dashboard-reset-progress-311
    • Pull Master Branch:
      MDL-70444-dashboard-reset-progress-m

      Description

      Running my_reset_page_for_all_users on a large site can be extremely slow. This makes it very prone to not running to completion. Because it is wrapped in a transaction it can hog things for a long time and it also means when it fails you end up with nothing to show for it.

      https://github.com/moodle/moodle/blob/master/my/lib.php#L178-L212

      So potentially a few different thing which should improve things:

      1) Unroll the transaction, I can't see any  particular reason why they all need to be atomic. Only each individual user needs to be atomic

      2) I'd limit the sql to pages of say 100 or 1000 users and do them in batches and if we keep the transaction wrap it around each batch. Make sure the batches full contain or do not contain all the block instances and pages for a single user, easiest is to probably ignore the last user in the batch as they likely wrap over and we can process them in the next page.

      3) Add an argument for a progress bar so we can keep the calling page alive and show progress

      4) Show the progress bar on a new intermediate page and make sure the session is unlocked 

       

       

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              peterburnett Peter Burnett
              Reporter:
              brendanheywood Brendan Heywood
              Peer reviewer:
              Brendan Heywood
              Integrator:
              Jun Pataleta
              Tester:
              Janelle Barcega
              Participants:
              Component watchers:
              Amaia Anabitarte, Carlos Escobedo, Ferran Recio, Ilya Tregubov, Sara Arjona (@sarjona), Matteo Scaramuccia, Andrew Nicols, Dongsheng Cai, Huong Nguyen, Jun Pataleta, Michael Hawkins, Shamim Rezaie, Simey Lameze
              Votes:
              4 Vote for this issue
              Watchers:
              11 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved:
                Fix Release Date:
                10/May/21

                  Time Tracking

                  Estimated:
                  Original Estimate - Not Specified
                  Not Specified
                  Remaining:
                  Remaining Estimate - 0 minutes
                  0m
                  Logged:
                  Time Spent - 5 hours
                  5h