Ticket #2252 (closed defect: worksforme)
FastCGI gets a timeout but renders correct pages afterwards
| Reported by: | thomas.jachmann@… | Owned by: | mgood |
|---|---|---|---|
| Priority: | normal | Milestone: | |
| Component: | general | Version: | 0.9.4 |
| Severity: | normal | Keywords: | |
| Cc: | thomas.jachmann@… |
Description
From time to time (every 5 to 10 requests), trac hangs. This is the output of apache's error log:
[Thu Oct 20 21:33:01 2005] [error] [client ...] FastCGI: comm with server "/usr/share/trac/cgi-bin/trac.fcgi" aborted: idle timeout (30 sec), referer: [...] [Thu Oct 20 21:33:01 2005] [error] [client ...] FastCGI: server "/usr/share/trac/cgi-bin/trac.fcgi" stderr: Traceback (most recent call last):, referer: [...] [Thu Oct 20 21:33:01 2005] [error] [client ...] FastCGI: server "/usr/share/trac/cgi-bin/trac.fcgi" stderr: File "/usr/lib/python2.3/site-packages/trac/web/_fcgi.py", line 567, in run, referer: [...] [Thu Oct 20 21:33:01 2005] [error] [client ...] FastCGI: server "/usr/share/trac/cgi-bin/trac.fcgi" stderr: protocolStatus, appStatus = self.server.handler(self), referer: [...] [Thu Oct 20 21:33:01 2005] [error] [client ...] FastCGI: server "/usr/share/trac/cgi-bin/trac.fcgi" stderr: TypeError: unpack non-sequence, referer: [...]
The first line only appears when the request hangs, the remaining four lines are written to the error log for each - even not-hanging - request.
This seems to be an error with trac.fcgi. Parts of the page are rendered, then it hangs for 30 seconds (the FastCGI timeout). Then, the rest of the page is passed to the browser and gets rendered. Nothing is broken. From the browser's view, it just looks like the server takes a break in the middle of the page. I just don't understand the timeout - this seems as if trac.fcgi execution gets cancelled by FastCGI, but still all content gets back to the browser in the end.
The following is my current apache configuration for the virtual host running trac. I run several projects off the root of the virtual host, avoiding the trac.fcgi script in the URL by using the ScriptAliasMatch directive. This is all taken from trac's documentation.
FastCgiConfig -initial-env TRAC_ENV_PARENT_DIR=/var/trac/ -idle-timeout 1
<VirtualHost *:80>
ServerName [...]
DocumentRoot /usr/share/trac/htdocs
<Directory "/usr/share/trac/htdocs">
Options Indexes MultiViews
AllowOverride None
Order allow,deny
Allow from all
</Directory>
AliasMatch ^/[^/]+/chrome/common(.*) /usr/share/trac/htdocs$1
ScriptAliasMatch ^(.*) /usr/share/trac/cgi-bin/trac.fcgi$1
</VirtualHost>
As you can see, I avoided the lag by just reducing the timeout of FastCGI to one second. This way, users don't notice that trac.fcgi gets a timeout. But with increasing load on the server, one second might not be sufficient.
I use:
- Fedora Core 3
- Apache 2.0.53
- Python 2.3.4
- Trac 0.9b2


