[plt-scheme] Re: web-server: connection timeout with open file handles

From: Jay McCarthy (jay.mccarthy at gmail.com)
Date: Wed Apr 22 11:02:22 EDT 2009

Regarding the file handles, I presume that are your file handles from
call-with-input-file?

When a servlet runs, its resources are owned by the servlet's
custodian, so they are shared by the entire servlet and not just the
instance or connection. This means that if you don't free resources,
it won't be removed until the servlet is, which only happens when you
conf/refresh-servlets.

Can you track down what kind of file handles are being retained? I
don't think that there's a problem with call-with-input-file, but I'd
like more info.

Jay

On Wed, Apr 22, 2009 at 8:07 AM, Dave Gurnell <d.j.gurnell at gmail.com> wrote:
> My initial diagnosis on this may have been wrong.
>
> I've added a line to instruct the web server to increase the connection
> timeout every so often.
> I get complete file downloads now, but file handles are still being left
> open.
>
> -- Dave
>
>> Hi all,
>>
>> I'm having a couple of issues with timeouts in the web server. This is
>> kind of related to the "dynamic-wind & kill-thread" thread.
>>
>> I'm using a servlet and make-response/incremental to serve files from the
>> file system to web users. I've attached simplified test code below (tested
>> on PLT 4.1.4.1).
>>
>> Three problems:
>>
>>  - large file downloads can take a long time, and can be killed by the web
>> server's connection timeout (default 60 seconds);
>>
>>  - when the connection times out, the servlet thread is killed and leaves
>> the file handle open permanently ("lsof -p <PID>").
>>
>>  - over time, the web server accrues open file handles until it hits the
>> OS-imposed limit ("ulimit -n")  and stops working properly (connecting to
>> Postgres in my case).
>>
>> I remember back in the day we had the same problem with files served using
>> dispatch-files.ss. The solution there was to insert a call to
>> adjust-connection-timeout! to increase the connection timeout for large
>> files.
>>
>> Here it's not so simple because make-response/incremental can do more than
>> just serve static files.
>>
>> I'd like to be able to call adjust-connection-timeout! from servlet code,
>> but I don't think that feature is available from inside a servlet (no access
>> to the connection object).
>>
>> Cheers,
>>
>> -- Dave
>
> _________________________________________________
>  For list-related administrative tasks:
>  http://list.cs.brown.edu/mailman/listinfo/plt-scheme
>



-- 
Jay McCarthy <jay at cs.byu.edu>
Assistant Professor / Brigham Young University
http://teammccarthy.org/jay

"The glory of God is Intelligence" - D&C 93


Posted on the users mailing list.