[php-maint] Bug#633100: Bug#633100: bad interaction with fuser bug in psmisc 22.14-1

Luka Frelih luka at ljudmila.org
Mon Jul 18 14:46:16 UTC 2011


hello!

craig, good idea to make the new potentially buggy behaviour an opt-in 
switch.

ondřej, this command  runs in acceptable time, around 10 seconds 
(similar to performance of find with stable fuser). but it does not 
actually delete anything, i tried it from cron as well as bash. seems 
that the find in /proc always returns false (despite being root) because 
there is a process it cannot find anymore, and the && before the last 
find short-circuits to false, not running the last stage

milci:/var/lib/php5# MAXTIME=$(/usr/lib/php5/maxlifetime) find /proc/ 
-mindepth 3 -maxdepth 3 -type l -regex '/proc/[0-9]*/fd/[0-9]*' -execdir 
bash -c 'X=$(readlink $0); [ -f "${X}" -a "${X:0:13}" = "/var/lib/php5" 
] && echo touch --date="-$((${MAXTIME}/2)) min" "${X}"' {} \; && find 
/var/lib/php5/ -depth -mindepth 1 -maxdepth 1 -type f -cmin 
+$(/usr/lib/php5/maxlifetime) ! -print
find: »/proc/18755/fd/5«: No such file or directory

milci:/var/lib/php5# MAXTIME=$(/usr/lib/php5/maxlifetime) find /proc/ 
-mindepth 3 -maxdepth 3 -type l -regex '/proc/[0-9]*/fd/[0-9]*' -execdir 
bash -c 'X=$(readlink $0); [ -f "${X}" -a "${X:0:13}" = "/var/lib/php5" 
] && echo touch --date="-$((${MAXTIME}/2)) min" "${X}"' {} \; && find 
/var/lib/php5/ -depth -mindepth 1 -maxdepth 1 -type f -cmin 
+$(/usr/lib/php5/maxlifetime) ! -print
find: »/proc/29163/fd/5«: No such file or directory
milci:/var/lib/php5#

so it seems close, but please check that echo before touch (seems wrong, 
hard to test as these files are not open for long in my case) and 
replace the last && with ;  i was using -print instead of -delete for 
testing to not have to wait for sessions to appear again.

LF


On 18. 07. 2011 15:38, Ondřej Surý wrote:
> Hi,
>
> since the scanning of the full /proc directory on every file in the
> /var/lib/php5 is very ineffective, I am probably going to remove the
> fuser call and replace it with something like this (rewritten to C for
> speed and less forks and bashisms removed):
>
> MAXTIME=$(/usr/lib/php5/maxlifetime) find /proc/ -mindepth 3 -maxdepth
> 3 -type l -regex '/proc/[0-9]*/fd/[0-9]*' -execdir bash -c
> 'X=$(readlink $0); [ -f "${X}" -a "${X:0:13}" = "/var/lib/php5" ]&&
> echo touch --date="-$((${MAXTIME}/2)) min" "${X}"' {} \;&&  find
> /var/lib/php5/ -depth -mindepth 1 -maxdepth 1 -type f -cmin
> +$(/usr/lib/php5/maxlifetime) ! -delete
>
> Basically this reads the /proc just once and sets the creating time to
> -maxlifetime/2 min in past.
>
> Luka, let me know if this helps.
>
> Ondrej
>
> On Mon, Jul 18, 2011 at 00:25, Craig Small<csmall at debian.org>  wrote:
>> On Sun, Jul 17, 2011 at 11:53:37PM +0200, Luka Frelih wrote:
>>> what i can confirm from investigation is that version 22.14-1 of
>>> fuser uses many times more resources - cpu and ram - than the stable
>>> version. why this is, i don't know. but used in the find for
>> That would be the forking that goes on to protect it against hanging
>> because of things like stat()ing nfs mounts etc.  It's not noticeable
>> to me, but it is to a lot of other people.
>>
>> I'm probably going to revert the change and make it an option.
>>
>>   - Craig
>> --
>> Craig Small VK2XLZ    http://www.enc.com.au/       csmall at : enc.com.au
>> Debian GNU/Linux      http://www.debian.org/       csmall at : debian.org
>> GPG fingerprint:       1C1B D893 1418 2AF4 45EE  95CB C76C E5AC 12CA DFA5
>>
>
>






More information about the pkg-php-maint mailing list