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

Cleanup of task logs fails with big number of records to be deleted

    XMLWordPrintable

Details

    • MOODLE_37_STABLE, MOODLE_38_STABLE, MOODLE_39_STABLE
    • MOODLE_37_STABLE, MOODLE_38_STABLE
    • master_MDL-67746
    • Hide

      1. Insert 100 000 records into `mdl_task_log` table:

      insert into mdl_task_log (type, component, classname, userid, timestart, timeend, dbreads, dbwrites, result, output) select 0, 'moodle', 'core\task\task_log_cleanup_task', 0, 1529580061+i, 1529580062+i, 5, 0,0, 'output' from generate_series(1,100000) i;

       2. Run scheduled task:

      php admin/tool/task/cli/schedule_task.php --showdebugging --execute='\core\task\task_log_cleanup_task'

       3. Confirm, that the task exits with no error:

      root@c3a08300483e:/siteroot# php admin/tool/task/cli/schedule_task.php --showdebugging --execute='\core\task\task_log_cleanup_task'
      Execute scheduled task: Cleanup of task logs (core\task\task_log_cleanup_task)
      ... used 107 dbqueries
      ... used 1.2285070419312 seconds
      Scheduled task complete: Cleanup of task logs (core\task\task_log_cleanup_task)
      
      

      Show
      1. Insert 100 000 records into `mdl_task_log` table: insert into mdl_task_log (type, component, classname, userid, timestart, timeend, dbreads, dbwrites, result, output) select 0, 'moodle', 'core\task\task_log_cleanup_task', 0, 1529580061+i, 1529580062+i, 5, 0,0, 'output' from generate_series(1,100000) i;  2. Run scheduled task: php admin/tool/task/cli/schedule_task.php --showdebugging --execute='\core\task\task_log_cleanup_task'  3.  Confirm , that the task exits with no error: root @c3a08300483e :/siteroot# php admin/tool/task/cli/schedule_task.php --showdebugging --execute= '\core\task\task_log_cleanup_task' Execute scheduled task: Cleanup of task logs (core\task\task_log_cleanup_task) ... used 107 dbqueries ... used 1.2285070419312 seconds Scheduled task complete: Cleanup of task logs (core\task\task_log_cleanup_task)

    Description

      If there are many records to delete '\core\task\task_log_cleanup_task' task can fail due to database limitation and throw an error (this one is for postgresql):

      Scheduled task failed: Cleanup of task logs (core\task\task_log_cleanup_task),Error writing to database
      Debug info:
      number of parameters must be between 0 and 65535
      

       

       Steps to replicate:

      1. Insert 100 000 records into `mdl_task_log` table:

      insert into mdl_task_log (type, component, classname, userid, timestart, timeend, dbreads, dbwrites, result, output) select 0, 'moodle', 'core\task\task_log_cleanup_task', 0, 1529580061+i, 1529580062+i, 5, 0,0, 'output' from generate_series(1,100000) i;
      

      2. Run scheduled task:

      php admin/tool/task/cli/schedule_task.php --showdebugging --execute='\core\task\task_log_cleanup_task'
      

       3. Confirm, that the error occurs.

      Attachments

        Issue Links

          Activity

            People

              mikhailgolenkov Misha Golenkov
              mikhailgolenkov Misha Golenkov
              Brendan Heywood Brendan Heywood
              Adrian Greeve Adrian Greeve
              Gladys Basiana Gladys Basiana
              Amaia Anabitarte, Carlos Escobedo, Ferran Recio, Ilya Tregubov, Laurent David, Sara Arjona (@sarjona)
              Votes:
              0 Vote for this issue
              Watchers:
              6 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:
                9/Mar/20

                Time Tracking

                  Estimated:
                  Original Estimate - 0 minutes
                  0m
                  Remaining:
                  Remaining Estimate - 0 minutes
                  0m
                  Logged:
                  Time Spent - 1 hour, 20 minutes
                  1h 20m