Merge ~cjwatson/launchpad:revert-better-oops-traceback-annotations into launchpad:master

Proposed by Colin Watson
Status: Merged
Approved by: Colin Watson
Approved revision: 3210bf7fc670573360a7e928b91f901b3fc26746
Merge reported by: Otto Co-Pilot
Merged at revision: not available
Proposed branch: ~cjwatson/launchpad:revert-better-oops-traceback-annotations
Merge into: launchpad:master
Diff against target: 67 lines (+11/-30)
2 files modified
lib/lp/services/timeline/requesttimeline.py (+11/-1)
lib/lp/services/webapp/tests/test_statementtracer.py (+0/-29)
Reviewer Review Type Date Requested Status
Jürgen Gmach Approve
Review via email: mp+438639@code.launchpad.net

Commit message

Partially revert timeline traceback handling changes

Description of the change

Formatting traceback supplements in timelines (commit d00b1f5c789e5fa4a19c2c4b13cbcf00d4ac6c04) results in recursive timeline actions via extra database queries in some cases, causing havoc in some tests. After exploring various options I regretfully decided to revert this.

I've retained most of the centralization of how `Timeline` objects are created, since that seems like a good idea regardless.

To post a comment you must log in.
Revision history for this message
Jürgen Gmach (jugmac00) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/lib/lp/services/timeline/requesttimeline.py b/lib/lp/services/timeline/requesttimeline.py
2index c529ace..d09b098 100644
3--- a/lib/lp/services/timeline/requesttimeline.py
4+++ b/lib/lp/services/timeline/requesttimeline.py
5@@ -71,7 +71,17 @@ def make_timeline(
6 factory = partial(FilteredTimeline, detail_filter=detail_filter)
7 else:
8 factory = Timeline
9- return factory(actions=actions, format_stack=format_stack)
10+ # XXX cjwatson 2023-03-09: Ideally we'd pass `format_stack=format_stack`
11+ # here so that we pick up traceback supplements. Unfortunately, the act
12+ # of formatting traceback supplements (e.g. TALESTracebackSupplement)
13+ # often turns out to involve database access, and the effect of that is
14+ # to recursively add a timeline action, which seems bad; it can also be
15+ # problematic for the parts of a timeline that immediately follow the
16+ # end of a transaction. Blocking database access here just results in a
17+ # traceback from the exception formatter, which isn't much better.
18+ # Until we find some solution to this, we'll have to live with plain
19+ # tracebacks.
20+ return factory(actions=actions)
21
22
23 def get_request_timeline(request):
24diff --git a/lib/lp/services/webapp/tests/test_statementtracer.py b/lib/lp/services/webapp/tests/test_statementtracer.py
25index 92351e0..383865d 100644
26--- a/lib/lp/services/webapp/tests/test_statementtracer.py
27+++ b/lib/lp/services/webapp/tests/test_statementtracer.py
28@@ -10,7 +10,6 @@ from contextlib import contextmanager
29 from lazr.restful.utils import get_current_browser_request
30
31 from lp.services.osutils import override_environ
32-from lp.services.tests.test_stacktrace import Supplement
33 from lp.services.timeline.requesttimeline import get_request_timeline
34 from lp.services.webapp import adapter as da
35 from lp.testing import (
36@@ -462,31 +461,3 @@ class TestLoggingWithinRequest(TestCaseWithFactory):
37 self.connection, None, "SELECT * FROM one", (), Exception()
38 )
39 self.assertIsNone(self.connection._lp_statement_action)
40-
41- def test_includes_traceback_supplement_and_info(self):
42- # The timeline records information from `__traceback_supplement__`
43- # and `__traceback_info__` in tracebacks.
44- tracer = da.LaunchpadStatementTracer()
45-
46- def call():
47- __traceback_supplement__ = (
48- Supplement,
49- {"expression": "something"},
50- )
51- __traceback_info__ = "Extra information"
52- tracer.connection_raw_execute(
53- self.connection, None, "SELECT * FROM one", ()
54- )
55-
56- with person_logged_in(self.person):
57- with StormStatementRecorder(tracebacks_if=True):
58- call()
59- timeline = get_request_timeline(get_current_browser_request())
60- self.assertRegex(
61- timeline.actions[-1].backtrace,
62- "\n"
63- " File .*, in call\n"
64- " .*\n"
65- " - Expression: something\n"
66- " - __traceback_info__: Extra information\n",
67- )

Subscribers

People subscribed via source and target branches

to status/vote changes: