r/drupal • u/pat-sohs-webmaster • 3d ago
Large Drupal 10 cache files even though tables are truncated
After Inmotion Hosting emptied our Drupal databases and then restored them because we exceeded storage limits, I began emptying the database caches every week in PHPMyAdmin. In spite of this, the cache files in the /var/lib/mysql/mydatabasename grew to 20 or more GBs. And now the websites have crashed again. I have read it isn't safe to delete the cache...ibd files, but if I don't I can't restore the database. IM has blown us off - they don't deal with databases. I do understand that, but it doesn't help solve the dilemma. Has anyone safely deleted the cache files? Everything online just tells me to empty the tables, and that clearly didn't eliminate the problem.
2
u/Glad_Professor9518 3d ago
It may be helpful to run optimize on your database. But I agree with the first commenter - bots may be hammering your site and filling up your cache (and possibly log? And search?) tables.
And I agree a Drupal-specific host is the move. At Drupito we’re looking for some complex projects to host to help further refine our Drupal-specific stack (includes Cloudflare). If you’re up for giving a try feel free to message me or email hello@drupito.com - we may be able to match your current hosting cost just for the case study.
Regardless, putting your site behind Cloudflare is a good idea. And you can even enable “under attack mode” to see if it stops the problem from recurring.
13
u/alphex https://www.drupal.org/u/alphex 3d ago
oh boy.
ok, please stop what you're doing, you're going to blow up your whole site.
_NEVER_ touch the actual files related to the database. You need to only manage this in your mysql commands, if you can't use drush to tell drupal what to do.
I'm guessing your getting hit with a lot of bot traffic, I would but the site behind cloudflare ASAP to reduce bot traffic, which is probably hammering the site, and generating cache files.
IF you only have access to PHPMYADMIN.
Then you want to run these commands.
```TRUNCATE TABLE cache_bootstrap; TRUNCATE TABLE cache_config; TRUNCATE TABLE cache_container; TRUNCATE TABLE cache_data; TRUNCATE TABLE cache_default; TRUNCATE TABLE cache_discovery; TRUNCATE TABLE cache_dynamic_page_cache; TRUNCATE TABLE cache_entity; TRUNCATE TABLE cache_menu; TRUNCATE TABLE cache_page; TRUNCATE TABLE cache_render; TRUNCATE TABLE cache_toolbar;```
PLEASE HAVE BACKUPS.
Then you'll need to look at mysql optimize commands to reduce the IDB file size usage.
---
With that said, you need to pay more for your hosting, or better, move to a better host.
3
u/eagletrance 3d ago
Move cache to Redis?
3
u/mrcaptncrunch 3d ago
You can also tune
database_cache_max_rowshttps://www.drupal.org/node/2891281
You also need to have cron running in order for it to truncate.
2
u/kerasai 3d ago
In order to reclaim disk space, I believe you may need to delete and recreate the tables rather than truncating.
An even better alternative would be to offload your cache to Redis or Valkey.