29 Martie 2014 Can't create/write to file /tmp ...

imaginea utilizatorului oana
Posted in Dev

Suddenly, while working on a website development, without doing any complex operation, I got the following error:

PDOException: SQLSTATE[HY000]: General error: 1 Can't create/write to file '/tmp/#sql_21d0_0.MYI' (Errcode: 28): SELECT sc.*, t.name AS name, t.description AS description, t.weight AS weight, t.vid AS vid FROM {simplenews_category} sc LEFT OUTER JOIN {taxonomy_term_data} t ON t.tid = sc.tid WHERE (block = :db_condition_placeholder_0) AND (opt_inout <> :db_condition_placeholder_1) ORDER BY t.weight ASC; Array ( [:db_condition_placeholder_0] => 1 [:db_condition_placeholder_1] => hidden ) in simplenews_categories_load_multiple() (line 1863 of /home ...

And this wasn't happening only on one website. I found multiple websites on the server with similar issue:

PDOException: SQLSTATE[HY000]: General error: 1 Can't create/write to file '/tmp/#sql_21d0_0.MYI' (Errcode: 28): SELECT DISTINCT registry.name AS name, registry.filename AS filename FROM {registry} registry WHERE (type=:type AND ( filename like :filename OR name like :name )) ; Array ( [:type] => class [:name] => %MailSystem [:filename] => %.mail.% ) în mailsystem_get_classes() ...

So, the things gone mad... I was in red alert? What should I do? It is Drupal's fault?!

The answer was ... no.  After some digging around, I found out that I might have a problem on the server side. The /tmp file was full and should be emptied. The cleaning of /tmp is done by the upstart script /etc/init/mounted-tmp.conf. The script is run by upstart everytime /tmp is mounted. That basically means at every reboot. But that is not all: the file deletion depends on the current value of TMPTIME variable, that should be checked:

  • TMPTIME = 0 means delete files at reboot despite the age of the file;
  • TMPTIME = 7 would allow files to stay in /tmp until they are a week old, and then delete them on the next reboot;
  • TMPTIME = -1, a negative number, tells the system to never delete anything in /tmp.

The solution, for the moment, was to clean the tmp file. In your case, a simple reboot, can save you.

Here is a script that I found, just use a cron entry to run it:

# Clean file and dirs more than 3 days old in /tmp nightly

/usr/bin/find /tmp -type f -atime +2 -mtime +2  |xargs  /bin/rm -f &&

/usr/bin/find /tmp -type d -mtime +2 -exec /bin/rm -rf '{}' \; &&

/usr/bin/find /tmp -type l -ctime +2 |xargs /bin/rm -f &&

/usr/bin/find -L /tmp -mtime +2 -print -exec rm -f {} \;

Poți adăuga un comentariu folosind și acest formular