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

stats_cron_monthly infinite loop for negative timezones

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: Minor Minor
    • None
    • 1.6.1
    • Libraries
    • None
    • All
    • Any
    • MOODLE_16_STABLE

      Description:

      When running admin/cron.php with stats generation, the while in stats_cron_monthly() in lib/statslib.php runs into a infinite loop and fills up the server space with junks in database (stats_monthly table).

      Affected setup:

      This bug affects servers in negative timezones with the correct local time set, but choose a negative GMT number in the timezone option under Variables in Administration.

      (bug does not affect negative timezone servers with timezone set to Server's local time)

      Action:

      running admin/cron.php (manually or scheduled)

      Coniditions:

      • The stats_daily, stats_weekly, and stats_monthly tables do not contain any previously created data (empty tables).
      • Administration/Configuration/Variables/Interface/timezone is set to a negative GMT.
      • Administration/Configuration/Variables/Statistics/enablestats is set to Yes
      • Administration/Configuration/Variables/Statistics/statsfirstrun is set to start at a time that's in the last month
      • Administration/Configuration/Variables/Statistics/statsmaxruntime is set to Until complete (might not have an effect on this bug?)

      Furthur observation:

      In stats_getdate() in lib/statslib.php, after the

      $time += intval((float)$timezone * HOURSECS);

      timezone adjustment, any negative timezone will be returned as an earlier time. This leads back to the while infinite loop in stats_cron_monthly():

      while ($monthend >= $nextmonthend) {

      Since nextmonthend is alwasys the same and smaller than monthend, this loop never ends. Server CPU goes 100%, database gets filled with junk data, all kind of wonderful things happen.

      Suggested Fix:

      • User: the timezone option should be set to Server's local time if the server is not using GMT(0).
      • Moodle: better description for the timezone option? additional server timezone check in statslib?

            dougiamas Martin Dougiamas
            imported Imported (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved:

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