In this commit, throttling on adding the check_status jobs was introduced: https://cgit.drupalcode.org/tmgmt_extension_suit/commit/?id=4702141e96b8...

The code that checks whether check_status jobs should be added is this:

/**
 * Returns TRUE if it's time to add items to check status queue.
 */
function tmgmt_extension_suit_is_add_to_check_status_cron_run_needed() {
  $interval = Drupal::config('tmgmt_extension_suit.settings')->get('interval');
  $cron_next = \Drupal::state()->get('system.cron_last', 0) + $interval;

  return ((int) \Drupal::time()->getRequestTime() > (int) $cron_next);
}

I believe the logic of this either provides no throttling, or prevents check_status jobs from ever being added, depending on the value of tmgmt_extension_suit.settings.interval.

system.cron_last is updated on every cron run. In order for check_status jobs to be added, the current request time needs to be interval seconds later than system.cron_last + interval.

If the interval at which cron is run is less than tmgmt_extension_suit.settings.interval, then system.cron_last + interval will always advance before the current request time. If the interval at which cron is run is greater than tmgmt_extension_suit.settings.interval, then check_status jobs will be added with every cron run.

I believe that in order for this throttle to be effective, TES would need to keep track of the last time check_status jobs were added, and check against that, rather than checking against system.cron_last

Comments

timcosgrove created an issue. See original summary.

timcosgrove’s picture

A more concrete example:

Let's assume system cron runs once an hour, or every 3600 seconds.

First, let's set tmgmt_extension_suit.settings.interval to its default, 10800 seconds, or 3 hours.

  1. Cron last ran at Tuesday, January 22, 2019 6:36:36 PM GMT, or 1548182196. This is system.cron_last
  2. Cron runs again at Tuesday, January 22, 2019 7:36:36 PM, or 1548185796. This is the request time.
  3. $cron_next is system.cron_last + tmgmt_extension_suit.settings.interval, or 1548192996.
  4. $cron_next is greater than the request time. ((int) \Drupal::time()->getRequestTime() > (int) $cron_next) returns false;
  5. system.cron_last is set to the current request time, 1548185796.
  6. An hour later, cron is run again. The request time is Tuesday, January 22, 2019 8:36:36 PM, or 1548189396.
  7. $cron_next is system.cron_last + tmgmt_extension_suit.settings.interval, or 1548196596.
  8. $cron_next is greater than the request time. ((int) \Drupal::time()->getRequestTime() > (int) $cron_next) returns false;
  9. system.cron_last is set to the current request time, 1548189396.
  10. etc.

It's easy to infer from this that if tmgmt_extension_suit.settings.interval is less than the cron interval, check_status will run, but it will run every cron run, and no throttling will take place.

loparev’s picture

Status: Active » Needs review
StatusFileSize
new8.37 KB

  • Loparev committed b269ac3 on 8.x-2.x
    Issue #3027655 by Loparev: Check status throttle prevents jobs from...
loparev’s picture

Status: Needs review » Fixed

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.