4

I have a lot of field_deleted_* tables in the database and neither drush cr or running cron is removing them. Is it okay to just remove them from the database? How can I tell Drupal to remove them otherwise?

enter image description here

Edit: Per 4k4 troubleshooting tip:

➜  default git:(HUHLR-172) ✗ drush ev "var_dump(\Drupal::state()->get('field.storage.deleted'))"
array(0) {
}

This means:

If this is empty, then you can remove the tables in the database as well, because Drupal has no chance to guess the hash keys of the table names without this information.

10

No, this is not a good idea, because there are more things that need to be removed, not only the database tables. Deleting these tables without checking their usage first (see troubleshooting below) results in this error Cron error message. table or view not found: 1146

The deleted fields are purged by cron, but only 50 rows per run. If you want to accelerate the process, run cron more often or increase the batch size in field.settings.yml:

purge_batch_size: 50

Instead of cron you can run field_purge_batch() from the command line, then with a higher batch limit, for example 1000 or how many rows you have and are able to delete without hitting a memory/time limit:

drush ev "field_purge_batch(1000)"

Troubleshooting

If cron or the drush command has no effect, even not deleting some of the rows (if there are any more rows left in the tables), then check whether there are still field storages registered for these tables:

drush ev "var_dump(\Drupal::state()->get('field.storage.deleted'))"

If this is empty, then you can remove the tables in the database as well, because Drupal has no chance to guess the hash keys of the table names without this information.

If this is not empty, then you can use this output of the field storage definition(s) to debug this further (see comment of @MarioSteinitz).

| improve this answer | |
  • @Kevin stated, that running Cron doesn't solve his problem. So there's probably a mismatched field definition error or a not cleanly uninstalled module preventing the purge batch from running without errors? – Mario Steinitz Jan 3 '18 at 23:34
  • Yeah, cron is having no effect. – Kevin Jan 4 '18 at 0:07
  • Looks like the troubleshooting tip provided 0 results, so I went ahead and deleted them from the DB. – Kevin Jan 4 '18 at 14:48
  • @Kevin ran into this issue too and cron does not seem to be removing the tables. Does drupal have a mechanism to remove the tables? – awm Apr 30 '18 at 20:15
  • If the drush command returns no results, you can delete the tables. – Kevin Apr 30 '18 at 20:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.