Merge lp:~stub/launchpad/bug-504291-disconnection-errors into lp:launchpad
| Status: | Merged |
|---|---|
| Approved by: | Stuart Bishop on 2010-01-19 |
| Approved revision: | not available |
| Merged at revision: | not available |
| Proposed branch: | lp:~stub/launchpad/bug-504291-disconnection-errors |
| Merge into: | lp:launchpad |
| Diff against target: |
194 lines (+78/-20) 4 files modified
lib/canonical/launchpad/webapp/dbpolicy.py (+4/-1) lib/canonical/launchpad/webapp/publication.py (+20/-4) lib/canonical/launchpad/webapp/tests/test_publication.py (+52/-15) lib/lp/scripts/utilities/importfascist.py (+2/-0) |
| To merge this branch: | bzr merge lp:~stub/launchpad/bug-504291-disconnection-errors |
| Related bugs: |
| Reviewer | Review Type | Date Requested | Status |
|---|---|---|---|
| Henning Eggers (community) | code | 2010-01-14 | Approve on 2010-01-18 |
|
Review via email:
|
|||
Commit Message
Detect, report and repair Storm Stores in an invalid state after handling a request.
| Stuart Bishop (stub) wrote : | # |
| Henning Eggers (henninge) wrote : | # |
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Thanks for fixing this annoying bug!
Since I cannot comment much in the actual fix, I found some things to
complain about in the test ... ;-)
> === modified file 'lib/canonical/
> --- lib/canonical/
> +++ lib/canonical/
> @@ -121,6 +121,43 @@
> # Ensure that it is different to the last logged OOPS.
> self.assertNotE
>
> + def test_bug_
I am not too fond of bug ids in method names. Could you find a different
name that fits for the situation when the oops is logged? I think it is
enough to refer to the bug number in the comment.
> + # Bug #504291 was that a Store was being left in a disconnected
> + # state after a request, causing subsequent requests handled by that
> + # thread to fail. We detect this state in endRequest and log an
> + # OOPS to help track down the trigger.
> + error_reporting
> + last_oops = error_reporting
> +
> + request = LaunchpadTestRe
> + publication = WebServicePubli
> + da.set_
I had to get the branch in order to understand what "da" is. How about
doing the import "as dbadapter"? That would be much clearer, if I
understood the abbreviation correctly. ;)
> +
> + # Disconnect a store
> + from canonical.
> + from canonical.
> + from storm.database import STATE_DISCONNECTED, STATE_RECONNECT
Why do you put these imports in here and not at the top of the file?
Please move them there (unless there is a circular import problem that I
am not aware of).
> + store = IMasterStore(
> + store._
> +
> + # Invoke the endRequest hook.
> + publication.
> +
> + next_oops = error_reporting
> +
> + # Ensure that it is different to the last logged OOPS.
> + self.assertNotE
> +
> + # Ensure the OOPS mentions the correct exception
> + self.assertNotE
Hm, returning -1 is a speciality of the find method but you are not
really comparing values here. This would read more natural as
self.
I think but I cannot be too sure about it.
> +
> + # Ensure the OOPS is correctly marked as informational only.
> + self.assertEqua
> +
> + # Ensure the store has been rolled back and in a usable state.
> + self.assertEqua
> + store.find(
Err, what is that last line about? Are you testing for an OOPS? Please
add a com...
| Stuart Bishop (stub) wrote : | # |
On Mon, Jan 18, 2010 at 11:54 PM, Henning Eggers <email address hidden> wrote:
>> + def test_bug_
>
> I am not too fond of bug ids in method names. Could you find a different
> name that fits for the situation when the oops is logged? I think it is
> enough to refer to the bug number in the comment.
Its now 'store_
>> + # Bug #504291 was that a Store was being left in a disconnected
>> + # state after a request, causing subsequent requests handled by that
>> + # thread to fail. We detect this state in endRequest and log an
>> + # OOPS to help track down the trigger.
>> + error_
>> + last_oops = error_reporting
>> +
>> + request = LaunchpadTestRe
>> + publication = WebServicePubli
>> + da.set_
>
> I had to get the branch in order to understand what "da" is. How about
> doing the import "as dbadapter"? That would be much clearer, if I
> understood the abbreviation correctly. ;)
Done.
>> + # Disconnect a store
>> + from canonical.
>> + from canonical.
>> + from storm.database import STATE_DISCONNECTED, STATE_RECONNECT
>
> Why do you put these imports in here and not at the top of the file?
> Please move them there (unless there is a circular import problem that I
> am not aware of).
I actually prefer it now from a readability POV as someone reading the test doesn't need to jump to the top of the file to see this information. I suspect I got into the habit dealing with circular imports though - stick them inline and you have one less thing to worry about breaking your tests.
I've moved them to the top per standard practice.
>> + store = IMasterStore(
>> + store.
>> +
>> + # Invoke the endRequest hook.
>> + publication.
>> +
>> + next_oops = error_reporting
>> +
>> + # Ensure that it is different to the last logged OOPS.
>> + self.assertNot
>> +
>> + # Ensure the OOPS mentions the correct exception
>> + self.assertNot
>
> Hm, returning -1 is a speciality of the find method but you are not
> really comparing values here. This would read more natural as
>
> self.assertTru
>
> I think but I cannot be too sure about it.
You mean self.assertTrue
I've changed it. Both seem equally readable to me.
>> + # Ensure the OOPS is correctly marked as informational only.
>> + self.assertEqu
>> +
>> +...

Bug #504291
It seems that somehow our database connections can be left in a disconnected state after a request has been handled. This stuffs up the next request handled by that thread.
This branch detects this case, logs a soft oops to help us track down the cause, and repairs the database connection to a usable state.