Problem uploading files (possibly an OS X issue?)

I have a running Rails application that uploads files back to the
server occasionally. I recently switched my development machine from a
Linux box to OS X 10.5, using the Apache server built-in on OS X and
mod_fcgid. I thought everything was fine until I recently tried to use
the file upload feature. If I specify a reasonable sized (164 Kb) file
for upload then I get an immediate error, before my controller even
gets to handle the request. This is what is in the log:

/!\ FAILSAFE /!\ Wed Jun 11 17:33:03 -0700 2008
  Status: 500 Internal Server Error
  protocol error
    /Library/Ruby/Gems/1.8/gems/actionpack-2.1.0/lib/action_controller/
request.r
b:573:in `read'
    /Library/Ruby/Gems/1.8/gems/actionpack-2.1.0/lib/action_controller/
request.r
b:573:in `read_multipart'
    /Library/Ruby/Gems/1.8/gems/actionpack-2.1.0/lib/action_controller/
request.r
b:547:in `loop'
    /Library/Ruby/Gems/1.8/gems/actionpack-2.1.0/lib/action_controller/
request.r
b:547:in `read_multipart'
    /Library/Ruby/Gems/1.8/gems/actionpack-2.1.0/lib/action_controller/
request.r
b:470:in `parse_multipart_form_parameters'
    /Library/Ruby/Gems/1.8/gems/actionpack-2.1.0/lib/action_controller/
request.r
b:400:in `parse_formatted_request_parameters'
    /Library/Ruby/Gems/1.8/gems/actionpack-2.1.0/lib/action_controller/
cgi_proce
ss.rb:80:in `request_parameters'
    /Library/Ruby/Gems/1.8/gems/actionpack-2.1.0/lib/action_controller/
request.r
b:304:in `parameters'
    /Library/Ruby/Gems/1.8/gems/actionpack-2.1.0/lib/action_controller/
request.r
b:22:in `request_method'
    /Library/Ruby/Gems/1.8/gems/actionpack-2.1.0/lib/action_controller/
request.r
b:35:in `method'
    /Library/Ruby/Gems/1.8/gems/actionpack-2.1.0/lib/action_controller/
routing/r
oute_set.rb:431:in `extract_request_environment'
    /Library/Ruby/Gems/1.8/gems/actionpack-2.1.0/lib/action_controller/
routing/r
oute_set.rb:384:in `recognize'
    /Library/Ruby/Gems/1.8/gems/actionpack-2.1.0/lib/action_controller/
dispatche
r.rb:148:in `handle_request'
    /Library/Ruby/Gems/1.8/gems/actionpack-2.1.0/lib/action_controller/
dispatche
r.rb:107:in `dispatch'
    /Library/Ruby/Gems/1.8/gems/actionpack-2.1.0/lib/action_controller/
dispatche
r.rb:104:in `synchronize'
    /Library/Ruby/Gems/1.8/gems/actionpack-2.1.0/lib/action_controller/
dispatche
r.rb:104:in `dispatch'
    /Library/Ruby/Gems/1.8/gems/actionpack-2.1.0/lib/action_controller/
dispatche
r.rb:120:in `dispatch_cgi'
    /Library/Ruby/Gems/1.8/gems/actionpack-2.1.0/lib/action_controller/
dispatche
r.rb:35:in `dispatch'
    /Library/Ruby/Gems/1.8/gems/rails-2.1.0/lib/fcgi_handler.rb:103:in
`process_
request'
    /Library/Ruby/Gems/1.8/gems/rails-2.1.0/lib/fcgi_handler.rb:153:in
`with_sig
nal_handler'
    /Library/Ruby/Gems/1.8/gems/rails-2.1.0/lib/fcgi_handler.rb:101:in
`process_
request'
    /Library/Ruby/Gems/1.8/gems/rails-2.1.0/lib/fcgi_handler.rb:78:in
`process_e
ach_request'
    /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/
ruby/gems/1.8
/gems/fcgi-0.8.7/lib/fcgi.rb:612:in `each_cgi'
    /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/
ruby/gems/1.8
/gems/fcgi-0.8.7/lib/fcgi.rb:609:in `each'
    /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/
ruby/gems/1.8
/gems/fcgi-0.8.7/lib/fcgi.rb:609:in `each_cgi'
    /Library/Ruby/Gems/1.8/gems/rails-2.1.0/lib/fcgi_handler.rb:77:in
`process_e
ach_request'
    /Library/Ruby/Gems/1.8/gems/rails-2.1.0/lib/fcgi_handler.rb:76:in
`catch'
    /Library/Ruby/Gems/1.8/gems/rails-2.1.0/lib/fcgi_handler.rb:76:in
`process_e
ach_request'
    /Library/Ruby/Gems/1.8/gems/rails-2.1.0/lib/fcgi_handler.rb:50:in
`process!'
    /Library/Ruby/Gems/1.8/gems/rails-2.1.0/lib/fcgi_handler.rb:24:in
`process!'
    /Users/tsanders/code/DFDialogDatabase/public/dispatch.fcgi:24

The fastcgi.crash.log just says:

[11/Jun/2008:17:33:07 :: 16969] asked to stop immediately
[11/Jun/2008:17:33:07 :: 16969] stopping after explicit exit

and the apache error_log says:

[Wed Jun 11 17:33:03 2008] [warn] (35)Resource temporarily
unavailable: mod_fcgid: write data to fastcgi server error
[Wed Jun 11 17:33:13 2008] [notice] mod_fcgid: process /Users/tsanders/
code/DFDialogDatabase/public/dispatch.fcgi(16969) exit(communication
error), terminated by calling exit(), return code: 0

The exact same code is still running on the production box, which is
running Linux along with Apache and mod_fcgid.

Does anybody have any clues what is wrong here? My guess is a borked
directory permission or something similar that is preventing the
storage of the file, but I'm hoping to not have to go figure out
what's happening inside actionpack. I don't know that this is specific
to the OS X install versus the Linux one, but that's my best guess at
the moment.

On 12 Jun 2008, at 02:50, Tim S

[Wed Jun 11 17:33:03 2008] [warn] (35)Resource temporarily
unavailable: mod_fcgid: write data to fastcgi server error
[Wed Jun 11 17:33:13 2008] [notice] mod_fcgid: process /Users/tsanders/
code/DFDialogDatabase/public/dispatch.fcgi(16969) exit(communication
error), terminated by calling exit(), return code: 0

The exact same code is still running on the production box, which is
running Linux along with Apache and mod_fcgid.

Does anybody have any clues what is wrong here? My guess is a borked
directory permission or something similar that is preventing the
storage of the file, but I'm hoping to not have to go figure out
what's happening inside actionpack. I don't know that this is specific
to the OS X install versus the Linux one, but that's my best guess at
the moment.

Does it work if use mongrel instead of mod_fcgid ?

Fred

Sorry for the double-post! This one took several hours to show up, so
I thought I had done it wrong.

I don't know. I don't have Mongrel running on any server to test it,
and frankly I was hoping to avoid changing to Mongrel in hopes of it
fixing this. This code has worked (and is still working) fine with
fcgid on other machines.

If the problem really requires changing the interface to the web
server than at the very least I think actionpack (where it crashes)
needs better error messages than "FAILSAFE protocol error", which
doesn't really give me very much to go on.

I don't know. I don't have Mongrel running on any server to test it,
and frankly I was hoping to avoid changing to Mongrel in hopes of it
fixing this. This code has worked (and is still working) fine with
fcgid on other machines.

I wasn't suggesting switching to mongrel to fix it, just as a means of
isolating it. Just running ruby script/server should get you up and
running with mongrel.

Fred

Oh. (blush) I hadn't realized it was that easy. My apologies!

So yes, it works with mongrel. I have a secondary problem from there
because I have some (bad and I should fix) code that assumes the
working directory is public, and it isn't with script/server, but the
params come in with what looks like a good temporary file like I
expected. I'll take a peek at cleaning up the path issue so I can at
least debug against mongrel.

I am still concerned about the actionpack crash with mod_fcgid and
Apache though. While I don't see that on the production server, I'd
sure like to know what's causing it.

Thanks for the help on showing me how to test mongrel!

Are you using Safari on the mac for testing? There are upload issues
with apache and Safari.. Try with firefox and see if you have the same
issue...

We had todo this on a form that uploaded to our rails app:

BrowserMatch Safari nokeepalive

And this can be nested in a <Location> element to only set the
nokeepalive for a section of your site.

Nope, I'm using Firefox v2.