[fpc-devel] "Unable to open file" on Linux randomly in a CGI application when using templates

Jonas Maebe jonas.maebe at elis.ugent.be
Mon Mar 15 10:58:43 CET 2010


On 15 Mar 2010, at 03:17, ABorka wrote:

> On 3/14/2010 16:08, Jonas Maebe wrote:
>>
>> On 14 Mar 2010, at 23:39, ABorka wrote:
>>
>>> I have a CGI application with a datamodule that is using templates  
>>> to generate the response pages (accessing a MySQL database through  
>>> ZEOS).
>>> Every once in a while, I'm getting an "Unable to open file"  
>>> exception that points to one of the templates the website is using.
>>>
>>> What could be the problem?
>>
>> Maybe you run out of file handles?
>>
> If that is the case, shouldn't something be in the syslog or some  
> other log?

No. It's a generic user error like any other.

> Is there any way I can check this for sure like last system error  
> string or something?

You can call sysutils.GetLastOSError and look up the number in errno.inc

> The exception message only says that "Unable to open file  
> <filepath_filename>".
>
> I checked the /proc/sys/fs/file-max  and it shows 294692

The per-user open file handles limit is different. You can see it in  
the output of "ulimit -a" under bash (if it says "unlimited", it means  
that it uses the system limit). Maybe you leak file handles somewhere.  
You can look in /proc/<pid>/fd from time to time to see whether the  
number of open files keeps growing over time.


Jonas



More information about the fpc-devel mailing list