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

    • MDL-68097-defer-events
    • 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.  

      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.

       

            Unassigned Unassigned
            brendanheywood Brendan Heywood
            Votes:
            1 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated:
              Resolved:

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