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

admin/cron.php infinite loop in backup_log_info caused when old logs are deleted

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Won't Fix
    • Affects Version/s: 1.6
    • Fix Version/s: None
    • Component/s: Backup, Libraries, Other
    • Labels:
      None
    • Database:
      Any
    • Affected Branches:
      MOODLE_16_STABLE

      Description

      It is possible for backup_log_info() (called from cron.php) to get into a (potentially) infinite loop when iterating over the logs. This can happen when one or more old log entries are deleted by another invocation of cron.php between the time when the current number of logs is determined by this line:

      $count_logs = count_records("log","course",$preferences->backup_course);

      and when the test to terminate the loop ("while ($counter < $count_logs)") is made and which should cause termination. If some logs have been deleted, the final call to get_records() may not return enough logs for the counter to equal $count_logs.

      I first identified and described this problem (without knowing the cause) here: http://moodle.org/mod/forum/discuss.php?d=50467#238903

      The following patch should fix the problem, but recognising that if get_records() doesn't return anything, then it's time to stop.

          • backuplib.php.orig Mon Jan 15 13:13:38 2007
          • backuplib.php Thu Apr 5 16:40:03 2007
            ***************
          • 1308,1313 ****
          • 1308,1317 ----
            backup_flush(300);
            }
            }
            + } else { + //No logs -- old ones were deleted by a different cron.php + //execution; break to avoid potentially infinite loop + break; }

            }
            //End logs tag

      I haven't yet had a chance to verify that this fix works. As this problem does not occur every single time backup_log_info(), a test case would need to be created.

        Gliffy Diagrams

          Attachments

            Activity

              People

              • Votes:
                1 Vote for this issue
                Watchers:
                2 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: