Drupal - "Fields pending deletion" stopping module unistall - how to delete manually?

It turns out that deleted fields in Drupal 8 are stored in the key_value table.

To find them:

select * from key_value where name = "field.field.deleted" or name = "field.storage.deleted"

The values are stored as a blob, but can be viewed (e.g. in phpmyadmin you can click on it to download, and view in vim or similar). The value does not make much sense to a human, but having gone through the code printing and error-logging various things it was clear to me that these entries were what was holding up the uninstall. I backed up the table and deleted the entries, and then was able to uninstall the module.

The same suggestion is made here in answer to a related issue:

https://drupal.stackexchange.com/a/230199/25792


I encountered the same issue with a field which was used in 7000+ entities, while the purge_batch_size: 1000 is not work, increase the number to over 7000 works.

So

purge_batch_size: 10000

works for my instance.

I solved this problem just by execute the following command:

drush php-eval 'field_purge_batch(10000);'

based on

https://drupal.stackexchange.com/a/261669/90460

then run

drush cron

then I can uninstall the module which was prevented.


The fields are deleted by cron runs. But only a fixed batch size. You can configure a higher value. If you can't use drush you can do this in UI. Go to the page /admin/config/development/configuration/single/import and add in field.settings a higher batch size:

purge_batch_size: 1000

and run cron again.

enter image description here