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
| Comment | File | Size | Author |
|---|---|---|---|
| #3 | tmgmt_extension_suit-check_status_cron_throttling-3027655.3.patch | 8.37 KB | loparev |
Comments
Comment #2
timcosgrove commentedA 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.
system.cron_last$cron_nextissystem.cron_last+tmgmt_extension_suit.settings.interval, or 1548192996.$cron_nextis greater than the request time.((int) \Drupal::time()->getRequestTime() > (int) $cron_next)returns false;system.cron_lastis set to the current request time, 1548185796.$cron_nextissystem.cron_last+tmgmt_extension_suit.settings.interval, or 1548196596.$cron_nextis greater than the request time.((int) \Drupal::time()->getRequestTime() > (int) $cron_next)returns false;system.cron_lastis set to the current request time, 1548189396.It's easy to infer from this that if
tmgmt_extension_suit.settings.intervalis less than the cron interval, check_status will run, but it will run every cron run, and no throttling will take place.Comment #3
loparev commentedComment #5
loparev commented