mogstored file descriptor leak

Cory Bennett mogile at corybennett.org
Sun Aug 14 23:52:48 PDT 2005


I found where the leak is originating.  The leaked files are only open read 
only.  So that excludes the code below.  So the only place left for me to 
look was in Perlbal.  I edited all the calls to aio_open to print out the 
fileno so I could track them via lsof.  All the leaked files were opened in 
Perlbal::ClientHTTPBase in  _serve_request (line 377).  This is the cvs 
version 1.51.

The code is still a bit too dense for me to follow, so I have no idea 
where/how the file should be getting closed.  I am hoping you have some 
ideas :)

Thanks
-Cory

On Sunday 14 August 2005 10:38 pm, Cory Bennett wrote:
> On Sunday 14 August 2005 8:40 pm, Brad Fitzpatrick wrote:
> > Great bug report.  I thought it'd be easy to find, but mogstored in cvs
> > (1.14) is pretty clear:
> >
> >             # open a file on that disk location called 'usage'
> >             my $rv = open(FILE, ">$disk/usage");
> >             unless ($rv) {
> >                 $err->("Unable to open '$disk/usage' for writing: $!");
> >                 next;
> >             }
> >             foreach (sort keys %$output) {
> >                 print FILE "$_: $output->{$_}\n";
> >             }
> >             close FILE;
>
> Yeah, It is the same version I am using.  I saw this code right away, and
> seemed obvious.  So I added a bunch of debug statements, printing out the
> $rv and also the fileno(FILE).  Using lsof I could see the file numbers,
> but the one printed by fileno(FILE) never showed up in lsof for mogstored. 
> My conclusion was that the above code is working correctly and that the
> leaked descriptor is coming from somewhere else.  I have been trying to
> find a 'clever' way to intercept the open and sysopen calls so I can get a
> stack trace, but I have not had much luck yet.
>
> -Cory


More information about the mogilefs mailing list