When a client terminates a connection
normalperson at yhbt.net
Fri Nov 30 19:26:20 UTC 2012
Andrew Stewart <boss at airbladesoftware.com> wrote:
> On 30 Nov 2012, at 00:04, Eric Wong wrote:
> > Iñaki Baz Castillo <ibc at aliax.net> wrote:
> >> I don't understand why the application on top of the HTTP/TCP layer
> >> (so the Rails app) should be interrupted because the TCP connection is
> >> closed prematurely. The HTTP layer (which involves a single TCP
> >> connection for each HTTP request/response pair) is a layer below the
> >> application layer, should not disturb the Rails app IMHO.
> >> Is this a design issue of Rails?
> > I suspect the the only possibility is when Rails is reading the
> > multipart response in a largish upload (any upload request which
> > can't fit in socket buffers).
> On the three occasions I've had this problem it's been a tiny request.
> The user clicks an ordinary Rails delete link. This POSTs to a URL
> with two parameters: an authenticity token and the _method.
> The corresponding destroy action looks like:
> def destroy
> client = Client.find params[:id] # 1 (ignores soft-deleted records)
> client.soft_delete # 2 (sets a deleted_at timestamp)
> client.brands.each(&:destroy) # 3 (a client has many brands)
> redirect_to clients_path
> Nginx logged:
> x.xxx.xx.xx - - [27/Nov/2012:14:40:28 +0000] "POST /clients/2248 HTTP/1.1" 499 0 "https://example.com/clients/2248/edit" "Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; WOW64; Trident/5.0)"
> x.xxx.xx.xx - - [27/Nov/2012:14:40:29 +0000] "POST /clients/2248 HTTP/1.1" 404 592 "https://example.com/companies/2248/edit" "Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; WOW64; Trident/5.0)"
> You can see the first request was terminated by the user. Hot on its
> heels the user tried again and got a 404.
Weird, and this is the only nginx instance that saw this request?
Also, according to your logs above, the two requests above came from
different Referer pages, so perhaps there were more requests involved
that hit a different nginx?
> The 404 was triggered by step 1 above: the first request had
> successfully soft-deleted the client. However the client's brands
> were still in the database. The first request had executed steps 1
> and 2 but not step 3.
> Unicorn didn't log anything. Rails didn't log the first request but
> did log the second.
Odd. It's been a long time since I looked at Rails; but doesn't Rails
log when a request _starts_? Also, doesn't Rails log all DB queries?
Or, by any chance, do you have query logging enabled in your DB to track
More information about the mongrel-unicorn