unicorn Ruby/Rack server user+dev discussion/patches/pulls/bugs/help
 help / color / mirror / code / Atom feed
From: Andrew Stewart <boss@airbladesoftware.com>
To: unicorn list <mongrel-unicorn@rubyforge.org>
Subject: Re: When a client terminates a connection
Date: Fri, 30 Nov 2012 10:15:17 +0100	[thread overview]
Message-ID: <C2EED9ED-8503-4E99-AA38-CDFCDBED0BDF@airbladesoftware.com> (raw)
In-Reply-To: <20121129230408.GA2618@dcvr.yhbt.net>

On 30 Nov 2012, at 00:04, Eric Wong wrote:
> Iñaki Baz Castillo <ibc@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
    end

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.

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.

I understand the steps to mitigate the problem...but I remain confused about why the Rails app was interrupted because the TCP connection was closed prematurely.

Yours,
Andrew Stewart
_______________________________________________
Unicorn mailing list - mongrel-unicorn@rubyforge.org
http://rubyforge.org/mailman/listinfo/mongrel-unicorn
Do not quote signatures (like this one) or top post when replying

  reply	other threads:[~2012-11-30  9:15 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-11-28 13:32 When a client terminates a connection Andrew Stewart
2012-11-28 21:10 ` Eric Wong
2012-11-29  8:38   ` Andrew Stewart
2012-11-29  9:17     ` Eric Wong
2012-11-29 11:24       ` Andrew Stewart
2012-11-29 17:09 ` Iñaki Baz Castillo
2012-11-29 17:09   ` Iñaki Baz Castillo
2012-11-29 23:04   ` Eric Wong
2012-11-30  9:15     ` Andrew Stewart [this message]
2012-11-30 19:26       ` Eric Wong
2012-12-03 14:42         ` Andrew Stewart

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://yhbt.net/unicorn/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=C2EED9ED-8503-4E99-AA38-CDFCDBED0BDF@airbladesoftware.com \
    --to=boss@airbladesoftware.com \
    --cc=mongrel-unicorn@rubyforge.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://yhbt.net/unicorn.git/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).