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

Make my_reset_page_for_all_users for dashboards more robust

XMLWordPrintable

    • MOODLE_311_STABLE, MOODLE_39_STABLE
    • MOODLE_311_STABLE
    • MDL-70444-dashboard-reset-progress-m
    • 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).

      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 

       

       

            peterburnett Peter Burnett
            brendanheywood Brendan Heywood
            Brendan Heywood Brendan Heywood
            Jun Pataleta Jun Pataleta
            Janelle Barcega Janelle Barcega
            Votes:
            4 Vote for this issue
            Watchers:
            11 Start watching this issue

              Created:
              Updated:
              Resolved:

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

                  Error rendering 'clockify-timesheets-time-tracking-reports:timer-sidebar'. Please contact your Jira administrators.