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

    • Testing Instructions:
      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)
    • Affected Branches:
      MOODLE_37_STABLE, MOODLE_38_STABLE, MOODLE_39_STABLE
    • Fixed Branches:
      MOODLE_37_STABLE, MOODLE_38_STABLE
    • Pull from Repository:
    • Pull 3.7 Branch:
      MOODLE_37_MDL-67746
    • Pull 3.8 Branch:
      MOODLE_38_MDL-67746
    • Pull Master Branch:
      master_MDL-67746

      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

              Assignee:
              mikhailgolenkov Mikhail Golenkov
              Reporter:
              mikhailgolenkov Mikhail Golenkov
              Peer reviewer:
              Brendan Heywood
              Integrator:
              Adrian Greeve
              Tester:
              Gladys Basiana
              Participants:
              Component watchers:
              Amaia Anabitarte, Carlos Escobedo, Ferran Recio, Sara Arjona (@sarjona), Víctor Déniz Falcón
              Votes:
              0 Vote for this issue
              Watchers:
              6 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved:
                Fix Release Date:
                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