During its operation, devel_themer creates files in /tmp, but then never removes them, causing /tmp to fill over time, possibly leading to server crash.
These files are generated in devel_themer_exit(). There's a comment about how "Writing to temp dir means [...] cleanup is free.", but this is not really the case, as /tmp is not necessarily cleaned every few hours. It would probably be useful to add a cleanup step, probably as devel_themer_cron() to avoid putting yet more code in normal page runs. If you think this is a good idea, I can write it.
Comments
Comment #1
moshe weitzman commentedthis module is intended to be used by a single person of an elevated role for a short duration. you would never turn it on for all users since the pages break and show checkboxes and such.
this is an extremely unlikely error condition. did you actually experience it or are you speculating?
Comment #2
fgmNo, this is not speculation. I found out about the problem the hard way while developing a theme because the server constantly crashed on me and
dfpointed me to the problem.A simple workaround for the problem is to set drupal to use a tmpdir outside the default
/tmp, but then of course, there is no automatic cleanup since other directories are not normally emptied periodically, and someone/somecode has to care about it. For now, I've set up a non-drupal cron to clean these files, but I suppose not all users have the same latitude.Comment #3
moshe weitzman commentedComment #4
i.chris.jacob commentedI had the same issue /tmp was allocated 100MB - which filled up very quickly. I believe some form of clean-up should be part of Devel...
for me I only found out about the issue after getting this error:
user warning: Got error 122 from storage engine query: SELECT DISTINCT b.* FROM blocks b LEFT JOIN blocks_roles r ON b.module = r.module AND b.delta = r.delta WHERE b.theme = 'fourseasons' AND b.status = 1 AND (r.rid IN (2) OR r.rid IS NULL) ORDER BY b.region, b.weight, b.module in /home/sitback/apache/vhosts/tixnetwork/web/modules/block/block.module on line 407.
Then ran df -h in console and saw I had used 100% of my disk quota:
Filesystem Size Used Avail Use% Mounted on
/dev/vzfs 100MB 100MB 0 100% /tmp
If you still disagree that's fine... but I just thought I would bring up the issue once more.
Cheers mate
- Chris
Comment #5
dkg commentedThis is definitely a problem in the real world. This module needs to clean up after itself. grrr.
fgm, if you would develop a patch for this, it would be much appreciated.
Comment #6
moshe weitzman commentedOK, I would take a patch to clean this during cron.
Comment #7
fgmOK, here is one possible implementation.
Comment #8
fgmPatch variant: done using drupal API instead of plain PHP.
Comment #9
moshe weitzman commentedCommitted after a qick rename to devel_themer_cron().
Comment #10
ck9 commentedI just received this message from my ISP; pretty surprised by it really.
We found the module "devel" used by your drupal generates too many temporary files, puts them into the system folder /tmp and didn't remove the files late. It make /tmp out of free space and stops some services. So we had to block the module /devel in order to resolve the problem.
--
--
Kind regards,
So yes, it's definitely a problem in the real world. If the patch works then perhaps I'll refer them to this page and explain that this has now been resolved.
Comment #12
rinogo commentedJust want to say thanks to all those who helped get this issue fixed, as well as moshe for committing it. I've been doing a lot of development on one Drupal site in particular, and this bug caused the disk on the VPS to continue to fill up, until eventually the disk was completely full, with a whole 2GB of devel_themer_* files left over in /tmp.
So, thanks again! :)
Comment #13
frankfarm commentedHi, I experienced this problem recently with:
We are just getting started with Drupal and have a working installation on our development server. Drupal had been working properly, though we were starting to see slower page loads (or longer delays), and one day the following warnings appeared:
/admin/content/comment (Comments)
/admin/reports/dblog (Recent log entries)
Core and modules are current as of today, Monday, August 10, 2009. cron run manually results in no warnings or errors.
http://drupal.org/node/335529
looked similar to my problem, so I logged in as root and edited /etc/my.cnf as follows:
Before
After
(changing max_connections and query_cache_size) but when I revisited the pages above, both warnings remained, so I restored my.cnf to its original state.
I successfully repaired all tables with phpMyAdmin as suggested in
http://drupal.org/node/49851
but when I revisited the pages above, both warnings remained.
I looked in /tmp (should probably have done this earlier) and found (partial listing):
Based on information I found in
https://support.mayfirst.org/ticket/2159
and at
http://www.debian-administration.org/users/Steve/weblog/176
I executed
find /tmp -name 'devel_themer_*' -and -ctime +3 -and -type f -print | xargs rmas root and /tmp went from 100% used to 1% used. I refresh /admin/content/comment and /admin/reports/dblog -- the warnings are gone! Problem solved (for now)!
I turned off all the Devel modules to prevent the problem from recurring. However, I still have a few questions:
Thank you!
Comment #14
fumbling commentedI've been experiencing this same issue as well. The /tmp folder is filling up with themer files. But I'm using 6.x-1.16 (should I start a separate thread?). It's happening in two cases, separate installs on separate boxes. My strategy has been to simply delete the tmp files, about 50MB or so worth perhaps, but haven't tried any patches yet. Is there a production-safe stable patch or solution yet by any chance? Thanks for any help.
Comment #15
garethsprice commentedTemporary fix, but if you can edit your crontab file (crontab -e from shell, or via cpanel/similar), add the following line:
Will clear out devel's cache files every 45 minutes.
Comment #16
extexan commentedI checked the patch file (from earlier in this thread) and my version of devel already has that code in it. I ran cron manually, but the devel files in /tmp were not deleted. Perhaps it's because I am running multiple sites from one copy of Drupal. The devel files are in /tmp one level below the root, but perhaps the devel_themer_cleanup function (run by devel_themer_cron) is looking in mysiteroot/sites/mytestsite.com/tmp.
Or maybe the devel_themer_cron is not being run. Is there something I need to do to get it to run when I run cron for mytestsite.com?
Comment #17
extexan commentedNudge re: my previous post... any thoughts???
Comment #18
ikeigenwijs commentedI have also a flooded tmp dir.
latest dev version.
Comment #19
fgm@garethsprice #15: Actually, this will clean them every 60 minutes, 45 minutes after the hour, but that's normal use. I'd even suggest something more like
0-55/15 * * * * /usr/bin/wget -q -O - http://(your site)/cron.php > /dev/null
Which will clean every 10 minutes using devel's hook_cron implementation.
Comment #20
alpixel commentedHere is a quick n dirty patch to resolve this in the current version
Comment #21
moshe weitzman commentedComment #22
quantum_leap commentedgouaille:I have applied your patch but I don't think it's doing anything. Each time I refresh the page, I get devel_themer files in my windows->Temp folder that fill up the folder. Is that normal? On D7 here...
Comment #23
alpixel commentedActually that worked on a linux based machine. Didn't test it at all on a windows but you should take a look at the path and the slashes used to find files.
Comment #24
weynhamzI have tested the last patch,and it is working,but this devel_themer_cleanup() should be called while the module is disabling too.
Here is a patch for devel_themer.install.
Comment #25
mermentau commentedJust had to clean nearly 3 gigs of devel_themer files from /tmp dating back 5 months. I have the latest dev release which is Feb 25, 2011.
Comment #26
kenneth.venken commentedPorted to latest version
Comment #27
effulgentsia commentedHow about this instead?
Comment #28
kenneth.venken commentedI've tested your patch and the files created by devel_themer older than DRUPAL_MAXIMUM_TEMP_FILE_AGE are now deleted when cron is run.
It's strange that the file module defines FILE_STATUS_PERMANENT but doesn't define FILE_STATUS_TEMPORARY. Should this be reported as a bug?
Comment #29
blazindrop commentedKenneth: Did you test the patch in #26 or #27? The patch in #27 removes the cron hook so I think you tested #26.
Comment #30
kenneth.venken commentedI've tested #27.
setting $file->status = 0 will make this file a temporary file. Everytime cron runs, it will delete temporary files older than DRUPAL_MAXIMUM_TEMP_FILE_AGE = 21600s = 6h. So it's not necessary to implement a cron hook to delete temporary files. Drupal will take care of this automatically.
Comment #31
amonteroI was suffering the same and by looking at the code I've found that file_save_data is hardcoded to make files permanent, so no "free cleanup" by Drupal will be done.
I solved it by setting the file object status to 0 and resaving and everything works. It makes it a bit slower I suppose, but not a problem in a devel module, IMO.
I was going to post an issue, but seems that you got it fixed before. This is what happens if you don't search the issue queue first :S
Anyway, posting the patch just to confirm that #27 & #30 are the correct solutions for me too. As kenneth says, there's no need to cron hook any longer. I also suppose that cleanup related code can be safely removed.
My 2c.
Comment #32
kenneth.venken commentedCommitted #27 to master.
Comment #34
knalstaaf commentedI still had this issue with the latest version from the project page nonetheless…