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

Have ability for event observers to defer firing until after the sessions is closed

    XMLWordPrintable

    Details

    • Testing Instructions:
      Hide

      BEFORE PATCH

      1) Hack the standard log store to mimic it being expensive:

      +++ b/admin/tool/log/store/standard/classes/log/store.php
      @@ -66,6 +66,12 @@ class store implements \tool_log\log\writer, \core\log\sql_internal_table_reader
           protected function insert_event_entries($evententries) {
               global $DB;
       
      +for ($c=1; $c<5; $c++) {
      +    error_log("waiting $c");
      +    sleep(1);
      +flush();
      +}
      +
               $DB->insert_records('logstore_standard_log', $evententries);
      
      

      2) Visit any page which emits a log, such as the live logs page itself:

      http://moodle.local/report/loglive/index.php

      3) Confirm it takes ~5 seconds to load

      4) Quickly open up this url in 5 tabs, note that they block each other and will take ~25 seconds overall until the last one load.

      AFTER PATCH

      5) Repeat the loading 5 tabs and confirm that each pages takes 5 seconds but they load in parallel.

       

      Show
      BEFORE PATCH 1) Hack the standard log store to mimic it being expensive: +++ b/admin/tool/log/store/standard/classes/log/store.php @@ -66,6 +66,12 @@ class store implements \tool_log\log\writer, \core\log\sql_internal_table_reader protected function insert_event_entries( $evententries ) { global $DB ; + for ( $c =1; $c <5; $c ++) { + error_log ( "waiting $c" ); + sleep(1); + flush (); +} + $DB ->insert_records( 'logstore_standard_log' , $evententries ); 2) Visit any page which emits a log, such as the live logs page itself: http://moodle.local/report/loglive/index.php 3) Confirm it takes ~5 seconds to load 4) Quickly open up this url in 5 tabs, note that they block each other and will take ~25 seconds overall until the last one load. AFTER PATCH 5) Repeat the loading 5 tabs and confirm that each pages takes 5 seconds but they load in parallel.  
    • Fixed Branches:
      MOODLE_39_STABLE
    • Pull Master Branch:
      MDL-68097-defer-events

      Description

      Appending to the logs, or any other general event observer does it's work while holding the session open. Certain observers can be safely handled after the session is closed, and even better can be done in the background after closing the network connection.

       

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              brendanheywood Brendan Heywood
              Reporter:
              brendanheywood Brendan Heywood
              Participants:
              Component watchers:
              Andrew Nicols, Jun Pataleta, Michael Hawkins, Shamim Rezaie, Simey Lameze
              Votes:
              1 Vote for this issue
              Watchers:
              2 Start watching this issue

                Dates

                Created:
                Updated:
                Fix Release Date:
                9/Nov/20