Deleting entities takes very long

Created on 24 April 2024, 7 months ago

I'm facing an issue where deleting entities is extremely slow, taking several minutes to delete just one entity. I am having this problem when trying to delete it programmaticaly, but just discovered it also happens when trying to delete the entity in the drupal backend. This issue does not exist on nodes, just on the custom entities.

I have checked the SQL SHOW FULL PROCESSLIST, but didn't see any deleting process in action.

/**
 * Delete applications older then $days that have successfully been transfered to MySolution
 * 
 * @param int $days
 * @return int Number of applications deleted
 */
public function cleanup(int $days = 14): int {
    $storage = \Drupal::entityTypeManager()->getStorage('sollicitaties');
    $ids = \Drupal::entityQuery('sollicitaties')
        ->condition('sync_status', 'done')
        ->condition('application_date', time() - $days * 24 * 60 * 60, '<')
        ->execute();

    $apps = $storage->loadMultiple($ids);

    $count = 0;
    foreach ($apps as $app) {
        dump('I receive this instantly');
        $app->delete();
        dump('Receive this several minutes later');
        $count++;
    }
    return $count;
}
πŸ’¬ Support request
Status

Active

Version

10.0 ✨

Component
EntityΒ  β†’

Last updated about 20 hours ago

Created by

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Production build 0.71.5 2024