IOError: closed stream
david at academia.edu
Tue Sep 24 16:02:10 UTC 2013
I'm getting "IOError: closed stream" from inside Unicorn occasionally
and I don't know what to make of it. The stack trace looks like this:
unicorn (4.5.0) lib/unicorn/stream_input.rb:129:in `kgio_read' unicorn
(4.5.0) lib/unicorn/stream_input.rb:129:in `read_all' unicorn (4.5.0)
lib/unicorn/stream_input.rb:60:in `read' unicorn (4.5.0)
config/initializers/rack_request.rb:19:in `POST' rack (1.4.5)
Any suggestions what this might indicate? Is this what I should
legitimately expect to see if the browser closes the connection
It's happening only for POSTs, and a small percentage of them, but I
can't find any further pattern - a variety of content, usually quite
Currently we're running nginx in front of unicorn via a unix socket.
In this state the errors occur at an almost-negligible rate. I
experimented yesterday with moving instead to nginx in front of
varnish, on a separate machine, with varnish then talking to unicorn
via a TCP socket. In that configuration the errors increased
dramatically, although the majority of requests still succeeded.
As you can see we're running unicorn 4.5 and rack 1.4.5 - except that
I'm monkey-patching Rack::Request to backport the 1.5 POST method,
which transforms an earlier nil error in to this one. (On Ruby 2.0.0,
on an Ubuntu-precise box on AWS.)
Any relevant info or suggestions would be appreciated.
Apologies if this shows up as a double-post--my first attempt seems to
have been rejected because I didn't turn on plain text mode.
More information about the mongrel-unicorn