#1366 closed defect (fixed)
avoid calling req.finish() on closed HTTP connections
Reported by: | warner | Owned by: | warner |
---|---|---|---|
Priority: | minor | Milestone: | 1.9.0 |
Component: | code-frontend-web | Version: | 1.8.2 |
Keywords: | cleanup | Cc: | |
Launchpad Bug: |
Description
While reviewing #393 MDMF, I ran into some test failures which were related to an HTTP "GET" connection being closed by the client before the tahoe server had a chance to close it itself. I think it only occurs during the new tests added as part of the #393 patch, but it's not MDMF-specific.
Here's a patch to fix it. Note that Twisted-9.0 was the first version which started raising an error when you call request.finish() on a request that's already been closed, and it was also the first version to offer request.notifyFinish() to tell you when it's been closed. So this patch has to switch on hasattr(req, "notifyFinish") until the time we raise our dependency on Twisted to 9.0 or later.
Attachments (2)
Change History (17)
Changed at 2011-02-21T05:52:10Z by warner
comment:1 Changed at 2011-02-21T05:52:47Z by warner
- Keywords review-needed added
comment:2 Changed at 2011-02-21T05:53:15Z by zooko
- Owner set to zooko
- Status changed from new to assigned
comment:3 follow-up: ↓ 5 Changed at 2011-02-21T05:54:43Z by zooko
Could this have been related to #1278 (gateway won't serve any page; variety of interesting error messages in twistd.log)?
comment:4 Changed at 2011-02-21T05:56:10Z by davidsarah
- Keywords reviewed added; review-needed removed
Looks good to me. (I only eyeballed it, I didn't run it.)
comment:5 in reply to: ↑ 3 ; follow-up: ↓ 7 Changed at 2011-02-21T05:58:36Z by davidsarah
Replying to zooko:
Could this have been related to #1278 (gateway won't serve any page; variety of interesting error messages in twistd.log)?
That does look likely given the log message on #1278:
exceptions.RuntimeError: Request.finish called on a request after its connection was lost; use Request.notifyFinish to keep track of this.
comment:6 Changed at 2011-02-21T06:00:48Z by zooko
+1 on attachment:1366.dpatch . I would appreciate it if you could investigate #1278. Hopefully this fixes it! I seem to recall that it would happen when there were failures e.g. due to insufficient servers, and it looks like that might have gotten the Tahoe-LAFS web code into a bad state when Twisted >= 9.0 raised an exception from the Tahoe-LAFS web code's attempt to finish an already-finished connection, and that then the Tahoe-LAFS web code might have been unable to serve other requests after that.
Again, please remove the reviewed tag once you've pushed this patch to trunk (or suggest a different way to track that information).
comment:7 in reply to: ↑ 5 Changed at 2011-02-21T06:02:12Z by zooko
Replying to davidsarah:
Replying to zooko:
Could this have been related to #1278 (gateway won't serve any page; variety of interesting error messages in twistd.log)?
That does look likely given the log message on #1278:
exceptions.RuntimeError: Request.finish called on a request after its connection was lost; use Request.notifyFinish to keep track of this.
If my theory from comment:6 looks sufficiently likely to you then perhaps we should close #1278 as "MIA--presumed dead". It wasn't very reproducible by me -- perhaps there is an element of race condition between Twisted finishing the connection and Tahoe-LAFS finishing it ?
comment:8 Changed at 2011-02-21T06:16:33Z by "Brian Warner <warner@…
- Resolution set to fixed
- Status changed from assigned to closed
In 44466fbb1bad4ba0:
comment:9 Changed at 2011-02-21T06:16:55Z by warner
- Keywords reviewed removed
comment:10 Changed at 2011-09-25T04:10:34Z by davidsarah
- Keywords cleanup added
- Milestone changed from undecided to 1.9.0
- Priority changed from major to minor
- Resolution fixed deleted
- Status changed from closed to reopened
The main bug in this ticket is fixed for 1.9. However since the Twisted dependency has been raised to >= 10.1, the hasattr switch is no longer needed.
Changed at 2011-10-13T20:07:17Z by davidsarah
web/filenode.py: since we depend on Twisted >= 10.1, there is no need to check for the existence of 'req.notifyFinish', which was added in Twisted 9.0. closes #1366
comment:11 Changed at 2011-10-13T20:08:23Z by davidsarah
- Keywords review-needed added
- Owner changed from zooko to warner
- Status changed from reopened to new
comment:12 Changed at 2011-10-13T20:12:43Z by Brian Warner <warner@…>
- Resolution set to fixed
- Status changed from new to closed
In 587e31a8cf486031:
(The changeset message doesn't reference this ticket)
comment:13 Changed at 2011-10-13T20:13:19Z by warner
- Keywords review-needed removed
comment:14 Changed at 2011-10-20T20:24:29Z by Brian Warner <warner@…>
comment:15 Changed at 2012-01-22T00:14:19Z by nejucomo
I see similar behavior, but after briefly skimming the patches and assuming that filenode.py was specific to only some HTTP requests, I filed a new ticket: #1664
patch to avoid test failures with the #393 tests, but appropriate for trunk