Cron reports it's done long before it really is done

Created on 12 June 2012, over 12 years ago
Updated 16 September 2024, 3 months ago

Problem/Motivation

In Drupal 7/8, \Drupal\Core\Cron has cron report to watchdog a cheerful "Cron run completed" message after all the hook_cron() implementations are done, but before the queues are processed.

In a system that uses queues extensively (such as the API module that runs api.drupal.org), it's rather ridiculous, because cron can say it's finished after about a second, while queue processing takes considerably longer (several minutes). So if you're watching the log while interactively running cron, you'll see the "cron run completed" message, then a bunch of queue processing messages, and finally the cron process will actually be done some time later.

Actually, considerable processing can take place even in the cron shutdown functions, so even if you waited until after queue processing to report cron is complete, that could be misleading.

Proposed resolution

Move the watchdog message out of \Drupal\Core\Cron::setCronLastTime() into ::run(), so it happens after queues have run. Anything happening in a shutdown function is not really 'during cron' as such.

Remaining tasks

Create a patch that changes when the watchdog message is generated.

User interface changes

Cron will generate its watchdog completion message when it's actually done processing, instead of before it's really done.

API changes

None.

πŸ› Bug report
Status

Fixed

Version

11.0 πŸ”₯

Component
CronΒ  β†’

Last updated 23 days ago

No maintainer
Created by

πŸ‡ΊπŸ‡ΈUnited States jhodgdon Spokane, WA, USA

Live updates comments and jobs are added and updated live.
  • Novice

    It would make a good project for someone who is new to the Drupal contribution process. It's preferred over Newbie.

Sign in to follow issues

Merge Requests

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024