<?xml version="1.0"?>
<rss xmlns:dc="http://purl.org/dc/elements/1.1/" version="2.0">
  <channel>
    <title>Transition Technology: Ticket #583: tmp files on parrot exceeded inode limit</title>
    <link>http://localhost:8080/trac/ticket/583</link>
    <description>&lt;p&gt;
Users are attempting to purchase a DVD and the cart always zeros out even after attempts to update cart etc.
&lt;/p&gt;
&lt;p&gt;
Laura suggests that this may be a server issue and to start with Chris:
&lt;/p&gt;
&lt;p&gt;
The prob could v likely be on the hosting side, so be worth contacting Chris first (and mention can add to cart all okay when logged in, view cart and alter and get to billing page, so could be a session setting that's changed) -
&lt;/p&gt;
&lt;ol&gt;&lt;li&gt;Does the server have disk space left on /tmp. Session data is most likely written there. (sometimes this cart faff issue can happen because of that.)
&lt;/li&gt;&lt;/ol&gt;&lt;ol start="2"&gt;&lt;li&gt;Are the PHP Session settings correct/ have they changed recently? Chris can fix this if needing a tweakette in php.ini or other places in the underworld of those types of files.
&lt;/li&gt;&lt;/ol&gt;&lt;ol start="3"&gt;&lt;li&gt;DB could potentially need check/repair.
&lt;/li&gt;&lt;/ol&gt;&lt;p&gt;
Another one is the shop element relies on cookies so if a user has set browser to not accept cookies may poss not work! (but think thats something not to think about here, as I tested as both logged in and logged out with cookies set to work on my browser, logged out got the 'cart empty' faff factor like other users will be getting.)
&lt;/p&gt;
&lt;p&gt;
If Chris can't spot the bug (does sound server side and sessions related from a quick test here, haven't looked at the server logs, but if get a mo later will see if I can), poss good to chat and I can think some more on it, but first thoughts alert me mostly to server side, sometimes a roll back to php 5.2 clicks things back into place (but shouldn't be needed).  Be good to see if there is a correlation with any server changes/tweaks happening around same timing that the cart stopped working.  Keep me in the loop if it is a server fix-y thing as always interested to hear results on bug fixing on sites.
&lt;/p&gt;
</description>
    <language>en-us</language>
    <image>
      <title>Transition Technology</title>
      <url>/trac/chrome/site/TransitionNetwork-Logo-Web-Small.jpg</url>
      <link>http://localhost:8080/trac/ticket/583</link>
    </image>
    <generator>Trac 0.12.5</generator>
    <item>
      
        <dc:creator>chris</dc:creator>

      <pubDate>Mon, 02 Sep 2013 18:22:44 GMT</pubDate>
      <title>hours, status, totalhours changed; cc set</title>
      <link>http://localhost:8080/trac/ticket/583#comment:1</link>
      <guid isPermaLink="false">http://localhost:8080/trac/ticket/583#comment:1</guid>
      <description>
          &lt;ul&gt;
            &lt;li&gt;&lt;strong&gt;cc&lt;/strong&gt;
              &lt;em&gt;laura&lt;/em&gt; added
            &lt;/li&gt;
            &lt;li&gt;&lt;strong&gt;hours&lt;/strong&gt;
                changed from &lt;em&gt;0.0&lt;/em&gt; to &lt;em&gt;0.5&lt;/em&gt;
            &lt;/li&gt;
            &lt;li&gt;&lt;strong&gt;status&lt;/strong&gt;
                changed from &lt;em&gt;new&lt;/em&gt; to &lt;em&gt;accepted&lt;/em&gt;
            &lt;/li&gt;
            &lt;li&gt;&lt;strong&gt;totalhours&lt;/strong&gt;
                changed from &lt;em&gt;0.0&lt;/em&gt; to &lt;em&gt;0.5&lt;/em&gt;
            &lt;/li&gt;
          &lt;/ul&gt;
        &lt;p&gt;
There is an issue with disk space on /home -- files can't be created:
&lt;/p&gt;
&lt;pre class="wiki"&gt;cd /home
touch test.txt
  touch: cannot touch `test.txt': No space left on device
&lt;/pre&gt;&lt;p&gt;
However df doesn't report a problem:
&lt;/p&gt;
&lt;pre class="wiki"&gt;Filesystem            Size  Used Avail Use% Mounted on
/dev/xvda2            9.9G  4.1G  5.4G  44% /
tmpfs                1021M     0 1021M   0% /lib/init/rw
udev                  990M   36K  989M   1% /dev
tmpfs                1021M  4.0K 1021M   1% /dev/shm
/dev/xvda3            8.9G  5.1G  3.4G  61% /home
&lt;/pre&gt;&lt;p&gt;
There are a lot of tmp files that can be deleted:
&lt;/p&gt;
&lt;pre class="wiki"&gt;cd /home/recon/tmp
du -h
  1.2G    .
cd /home/movie/tmp/
du -h
 1.1G    .
&lt;/pre&gt;&lt;p&gt;
These seem to be tmp session files that don't get deleted, there are a lot of them:
&lt;/p&gt;
&lt;pre class="wiki"&gt;ls /home/recon/tmp/ | wc -l
294282
&lt;/pre&gt;&lt;p&gt;
So deleting the tmp files that are more than a day old:
&lt;/p&gt;
&lt;pre class="wiki"&gt;find /home/recon/tmp/* -mtime +1 -exec rm {} \;
find /home/movie/tmp/* -mtime +1 -exec rm {} \;
&lt;/pre&gt;&lt;p&gt;
Hopefully this will fix it for now, but more work is needed on this.
&lt;/p&gt;
      </description>
      <category>Ticket</category>
    </item><item>
      
        <dc:creator>chris</dc:creator>

      <pubDate>Tue, 03 Sep 2013 10:52:01 GMT</pubDate>
      <title>hours, totalhours changed</title>
      <link>http://localhost:8080/trac/ticket/583#comment:2</link>
      <guid isPermaLink="false">http://localhost:8080/trac/ticket/583#comment:2</guid>
      <description>
          &lt;ul&gt;
            &lt;li&gt;&lt;strong&gt;hours&lt;/strong&gt;
                changed from &lt;em&gt;0.0&lt;/em&gt; to &lt;em&gt;0.25&lt;/em&gt;
            &lt;/li&gt;
            &lt;li&gt;&lt;strong&gt;totalhours&lt;/strong&gt;
                changed from &lt;em&gt;0.5&lt;/em&gt; to &lt;em&gt;0.75&lt;/em&gt;
            &lt;/li&gt;
          &lt;/ul&gt;
        &lt;p&gt;
The server had run out of inodes (see &lt;a class="ext-link" href="https://en.wikipedia.org/wiki/Inode"&gt;&lt;span class="icon"&gt;​&lt;/span&gt;https://en.wikipedia.org/wiki/Inode&lt;/a&gt; ), not diskspace, there were over 1/2 a million tmp session files:
&lt;/p&gt;
&lt;pre class="wiki"&gt;269711 ./movie/tmp
294284 ./recon/tmp
&lt;/pre&gt;&lt;p&gt;
There is now lots of free inodes:
&lt;/p&gt;
&lt;pre class="wiki"&gt;df -i
Filesystem            Inodes   IUsed   IFree IUse% Mounted on
/dev/xvda2            655360   40647  614713    7% /
tmpfs                 261355       4  261351    1% /lib/init/rw
udev                  253188     384  252804    1% /dev
tmpfs                 261355       3  261352    1% /dev/shm
/dev/xvda3            589824   28674  561150    5% /home
&lt;/pre&gt;&lt;p&gt;
I have added a daily cron job to delete all tmp files that are more than 7 days old:
&lt;/p&gt;
&lt;pre class="wiki"&gt;01 06 * * * find /home/*/tmp/* -mtime +7 -exec rm {} \;
&lt;/pre&gt;&lt;p&gt;
I have added a section to the wiki about this, &lt;a class="wiki" href="http://localhost:8080/trac/wiki/ParrotServer#tmpfiles"&gt;wiki:ParrotServer#tmpfiles&lt;/a&gt;
&lt;/p&gt;
&lt;p&gt;
I think that resolves this issue?
&lt;/p&gt;
      </description>
      <category>Ticket</category>
    </item><item>
      
        <dc:creator>chris</dc:creator>

      <pubDate>Tue, 03 Sep 2013 12:28:38 GMT</pubDate>
      <title>hours, totalhours, summary changed</title>
      <link>http://localhost:8080/trac/ticket/583#comment:3</link>
      <guid isPermaLink="false">http://localhost:8080/trac/ticket/583#comment:3</guid>
      <description>
          &lt;ul&gt;
            &lt;li&gt;&lt;strong&gt;hours&lt;/strong&gt;
                changed from &lt;em&gt;0.0&lt;/em&gt; to &lt;em&gt;0.25&lt;/em&gt;
            &lt;/li&gt;
            &lt;li&gt;&lt;strong&gt;totalhours&lt;/strong&gt;
                changed from &lt;em&gt;0.75&lt;/em&gt; to &lt;em&gt;1.0&lt;/em&gt;
            &lt;/li&gt;
            &lt;li&gt;&lt;strong&gt;summary&lt;/strong&gt;
                changed from &lt;em&gt;Problem with intransition movie site shopping cart&lt;/em&gt; to &lt;em&gt;tmp files on parrot exceeded inode limit&lt;/em&gt;
            &lt;/li&gt;
          &lt;/ul&gt;
        &lt;p&gt;
For reference the number of inodes on the /home aka /dev/xvda3 partition is 589,824 and this is the limit that was hit:
&lt;/p&gt;
&lt;pre class="wiki"&gt;tune2fs -l /dev/xvda3
...
Filesystem OS type:       Linux
Inode count:              589824
Block count:              2359296
Reserved block count:     117964
Free blocks:              1551253
Free inodes:              561780
First block:              0
Block size:               4096
Fragment size:            4096
Reserved GDT blocks:      575
Blocks per group:         32768
Fragments per group:      32768
Inodes per group:         8192
Inode blocks per group:   512
&lt;/pre&gt;&lt;p&gt;
We could consider creating a new partition just for tmp files with a inode count of several million if there is an issue with tmp session files being deleted after a week -- is this a problem, does it cause people to be logged out?
&lt;/p&gt;
      </description>
      <category>Ticket</category>
    </item><item>
      
        <dc:creator>ed</dc:creator>

      <pubDate>Tue, 03 Sep 2013 12:40:40 GMT</pubDate>
      <title></title>
      <link>http://localhost:8080/trac/ticket/583#comment:4</link>
      <guid isPermaLink="false">http://localhost:8080/trac/ticket/583#comment:4</guid>
      <description>
        &lt;p&gt;
Good work Chris - thanks.
&lt;/p&gt;
&lt;p&gt;
I'm going to ask Laura to have a scan of this ticket - to developer-sense-check it - and see how/if it ties in with the larger piece of work around the whole site and updating it - which would need separate budget from TN...
&lt;/p&gt;
      </description>
      <category>Ticket</category>
    </item><item>
      
        <dc:creator>chris</dc:creator>

      <pubDate>Thu, 12 Sep 2013 09:04:28 GMT</pubDate>
      <title>hours, status, totalhours changed; resolution set</title>
      <link>http://localhost:8080/trac/ticket/583#comment:5</link>
      <guid isPermaLink="false">http://localhost:8080/trac/ticket/583#comment:5</guid>
      <description>
          &lt;ul&gt;
            &lt;li&gt;&lt;strong&gt;hours&lt;/strong&gt;
                changed from &lt;em&gt;0.0&lt;/em&gt; to &lt;em&gt;0.5&lt;/em&gt;
            &lt;/li&gt;
            &lt;li&gt;&lt;strong&gt;status&lt;/strong&gt;
                changed from &lt;em&gt;accepted&lt;/em&gt; to &lt;em&gt;closed&lt;/em&gt;
            &lt;/li&gt;
            &lt;li&gt;&lt;strong&gt;resolution&lt;/strong&gt;
                set to &lt;em&gt;fixed&lt;/em&gt;
            &lt;/li&gt;
            &lt;li&gt;&lt;strong&gt;totalhours&lt;/strong&gt;
                changed from &lt;em&gt;1.0&lt;/em&gt; to &lt;em&gt;1.5&lt;/em&gt;
            &lt;/li&gt;
          &lt;/ul&gt;
        &lt;p&gt;
The cronjob failed last night:
&lt;/p&gt;
&lt;pre class="wiki"&gt;From: root@parrot.webarch.net (Cron Daemon)
Date: Thu, 12 Sep 2013 06:01:01 +0100
To: root@parrot.webarch.net
Subject: Cron &amp;lt;root@parrot&amp;gt; find /home/*/tmp/* -mtime +7 -exec rm {} \; (failed)
/bin/sh: find: Argument list too long
&lt;/pre&gt;&lt;p&gt;
It also failed when piping to rm:
&lt;/p&gt;
&lt;pre class="wiki"&gt;find /home/*/tmp/* -mtime +7 | xargs rm -rf
-bash: /usr/bin/find: Argument list too long
&lt;/pre&gt;&lt;p&gt;
And ls fails when trying to count the files:
&lt;/p&gt;
&lt;pre class="wiki"&gt;ls /home/*/tmp/* | wc -l
-bash: /bin/ls: Argument list too long
0
&lt;/pre&gt;&lt;p&gt;
Debian has a package called &lt;tt&gt;tmpreaper&lt;/tt&gt;, so:
&lt;/p&gt;
&lt;pre class="wiki"&gt;aptitude install tmpreaper ; logchange "tmpreaper: installed"
&lt;/pre&gt;&lt;p&gt;
The &lt;tt&gt;/etc/tmpreaper.conf&lt;/tt&gt; file was edited and these values were set:
&lt;/p&gt;
&lt;pre class="wiki"&gt;TMPREAPER_DIRS='/home/*/tmp/.'
TMPREAPER_TIME='7d'
&lt;/pre&gt;&lt;p&gt;
And it was tested on the command line:
&lt;/p&gt;
&lt;pre class="wiki"&gt;/etc/cron.daily/tmpreaper
error: Cannot chdir() to `/home/*/tmp/.' for --protect glob: No such file or directory
&lt;/pre&gt;&lt;p&gt;
So we have to specify the directories without a wild card:
&lt;/p&gt;
&lt;pre class="wiki"&gt;TMPREAPER_DIRS='/home/recon/tmp/. /home/movie/tmp/.'
&lt;/pre&gt;&lt;p&gt;
And it was run again and then the number of files remaining was countable again:
&lt;/p&gt;
&lt;pre class="wiki"&gt;/etc/cron.daily/tmpreaper
ls /home/*/tmp/* | wc -l
42963
&lt;/pre&gt;&lt;p&gt;
And the documentation has been updated, &lt;a class="wiki" href="http://localhost:8080/trac/wiki/ParrotServer#tmpfiles"&gt;wiki:ParrotServer#tmpfiles&lt;/a&gt;
&lt;/p&gt;
      </description>
      <category>Ticket</category>
    </item>
 </channel>
</rss>