Date Published: August 16, 2023
Clearing out expired fields in your databases - the untold wonders of Drupal Cron
Issue¶
A database table, such as the key_value_expire
table, is filled with expired entries. Large tables with outdated information can cause maintenance and performance issues, and even service interruptions.
Resolution¶
The fix is to purge all of the entries which have an expire date that has already passed. Running your site's Drupal Cron regularly does this.
Looking at D.O's Cron automated tasks overview you will see that there are four bullet points regarding tasks that a properly configured cron job can manage:
- Updates the index of site content used by the Search module.
- Queues feeds to be updated by the Aggregator module.
- Checks for available updates for the Update Manager module.
- Performs routine maintenance tasks, such as removing older rows from logs, for the System module.
Looking deeper into core/modules/system/system.module
, you can see:
function system_cron() {
// Clean up the flood.
\Drupal::flood()->garbageCollection();
foreach (Cache::getBins() as $cache_backend) {
$cache_backend->garbageCollection();
}
// Clean up the expirable key value database store.
if (\Drupal::service('keyvalue.expirable.database') instanceof KeyValueDatabaseExpirableFactory) {
\Drupal::service('keyvalue.expirable.database')->garbageCollection();
}
For additional reference you can also see:
Cause ¶
Disabling Drupal Cron for a prolonged period of time.
Did not find what you were looking for?
If this content did not answer your questions, try searching or contacting our support team for further assistance.