Comment 25 for bug 1466549

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to swift (stable/kilo)

Reviewed: https://review.openstack.org/217750
Committed: https://git.openstack.org/cgit/openstack/swift/commit/?id=036c2f348d24c01c7a4deba3e44889c45270b46d
Submitter: Jenkins
Branch: stable/kilo

commit 036c2f348d24c01c7a4deba3e44889c45270b46d
Author: Samuel Merritt <email address hidden>
Date: Thu Jun 18 12:58:03 2015 -0700

    Get better at closing WSGI iterables.

    PEP 333 (WSGI) says: "If the iterable returned by the application has
    a close() method, the server or gateway must call that method upon
    completion of the current request[.]"

    There's a bunch of places where we weren't doing that; some of them
    matter more than others. Calling .close() can prevent a connection
    leak in some cases. In others, it just provides a certain pedantic
    smugness. Either way, we should do what WSGI requires.

    Noteworthy goofs include:

      * If a client is downloading a large object and disconnects halfway
        through, a proxy -> obj connection may be leaked. In this case,
        the WSGI iterable is a SegmentedIterable, which lacked a close()
        method. Thus, when the WSGI server noticed the client disconnect,
        it had no way of telling the SegmentedIterable about it, and so
        the underlying iterable for the segment's data didn't get
        closed.

        Here, it seems likely (though unproven) that the object server
        would time out and kill the connection, or that a
        ChunkWriteTimeout would fire down in the proxy server, so the
        leaked connection would eventually go away. However, a flurry of
        client disconnects could leave a big pile of useless connections.

      * If a conditional request receives a 304 or 412, the underlying
        app_iter is not closed. This mostly affects conditional requests
        for large objects.

    The leaked connections were noticed by this patch's co-author, who
    made the changes to SegmentedIterable. Those changes helped, but did
    not completely fix, the issue. The rest of the patch is an attempt to
    plug the rest of the holes.

    Co-Authored-By: Romain LE DISEZ <email address hidden>

    Closes-Bug: #1466549

    Change-Id: I168e147aae7c1728e7e3fdabb7fba6f2d747d937
    (cherry picked from commit 12d8a53fffea6e4bed8ba3d502ce625f5c6710b9
    with fixed import conflicts)