Merge lp:~lifeless/launchpad/bug-607960 into lp:launchpad

Proposed by Robert Collins
Status: Merged
Approved by: Robert Collins
Approved revision: no longer in the source branch.
Merged at revision: 12374
Proposed branch: lp:~lifeless/launchpad/bug-607960
Merge into: lp:launchpad
Diff against target: 82 lines (+33/-3)
3 files modified
lib/lp/bugs/model/bugtask.py (+9/-3)
lib/lp/bugs/tests/test_bugtask_search.py (+20/-0)
lib/lp/services/features/flags.py (+4/-0)
To merge this branch: bzr merge lp:~lifeless/launchpad/bug-607960
Reviewer Review Type Date Requested Status
Robert Collins (community) Approve
Review via email: mp+49588@code.launchpad.net

Commit message

[r=lifeless][ui=none][bug=607960] Permit turning targetnamecache off via malone.disable_targetnamesearch feature flag.

Description of the change

LIKE searching in targetnamecache is very expensive, this allows it to be disabled so we can see the true impact and assess its usability impacts.

To post a comment you must log in.
Revision history for this message
Robert Collins (lifeless) wrote :

self review

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'lib/lp/bugs/model/bugtask.py'
2--- lib/lp/bugs/model/bugtask.py 2011-02-13 23:02:49 +0000
3+++ lib/lp/bugs/model/bugtask.py 2011-02-14 04:47:18 +0000
4@@ -163,6 +163,7 @@
5 from lp.registry.interfaces.sourcepackagename import ISourcePackageNameSet
6 from lp.registry.model.pillar import pillar_sort_key
7 from lp.registry.model.sourcepackagename import SourcePackageName
8+from lp.services import features
9 from lp.services.propertycache import get_property_cache
10 from lp.soyuz.enums import PackagePublishingStatus
11 from lp.soyuz.model.publishing import SourcePackagePublishingHistory
12@@ -2205,9 +2206,14 @@
13 AND MessageChunk.fti @@ ftq(%s))""" % searchtext_quoted
14 text_search_clauses = [
15 "Bug.fti @@ ftq(%s)" % searchtext_quoted,
16- "BugTask.fti @@ ftq(%s)" % searchtext_quoted,
17- "BugTask.targetnamecache ILIKE '%%' || %s || '%%'" % (
18- searchtext_like_quoted)]
19+ "BugTask.fti @@ ftq(%s)" % searchtext_quoted
20+ ]
21+ no_targetnamesearch = bool(features.getFeatureFlag(
22+ 'malone.disable_targetnamesearch'))
23+ if not no_targetnamesearch:
24+ text_search_clauses.append(
25+ "BugTask.targetnamecache ILIKE '%%' || %s || '%%'" % (
26+ searchtext_like_quoted))
27 # Due to performance problems, whether to search in comments is
28 # controlled by a config option.
29 if config.malone.search_comments:
30
31=== modified file 'lib/lp/bugs/tests/test_bugtask_search.py'
32--- lib/lp/bugs/tests/test_bugtask_search.py 2011-02-06 21:58:31 +0000
33+++ lib/lp/bugs/tests/test_bugtask_search.py 2011-02-14 04:47:18 +0000
34@@ -44,6 +44,7 @@
35 from lp.registry.interfaces.product import IProduct
36 from lp.registry.interfaces.sourcepackage import ISourcePackage
37 from lp.registry.model.person import Person
38+from lp.services.features.testing import FeatureFixture
39 from lp.testing import (
40 person_logged_in,
41 StormStatementRecorder,
42@@ -755,6 +756,25 @@
43 subscriber, subscribed_by=subscriber)
44 return subscriber
45
46+ def test_disable_targetnames_search(self):
47+ # searching in the target name is contentious and arguably a bug. To
48+ # permit incremental changes we allow it to be disabled via a feature
49+ # flag.
50+ with person_logged_in(self.owner):
51+ product1 = self.factory.makeProduct(name='product-foo',
52+ owner=self.owner, project=self.searchtarget)
53+ product2 = self.factory.makeProduct(name='product-bar',
54+ owner=self.owner, project=self.searchtarget)
55+ bug1 = self.factory.makeBug(product=product1)
56+ bug1.default_bugtask.updateTargetNameCache()
57+ bug2 = self.factory.makeBug(product=product2)
58+ params = self.getBugTaskSearchParams(user=None, searchtext='uct-fo')
59+ # With no flag, we find the first bug.
60+ self.assertSearchFinds(params, [bug1.default_bugtask])
61+ with FeatureFixture({'malone.disable_targetnamesearch': u'on'}):
62+ # With a flag set, no bugs are found.
63+ self.assertSearchFinds(params, [])
64+
65
66 class MilestoneTarget(BugTargetTestBase):
67 """Use a milestone as the bug target."""
68
69=== modified file 'lib/lp/services/features/flags.py'
70--- lib/lp/services/features/flags.py 2011-02-07 07:10:54 +0000
71+++ lib/lp/services/features/flags.py 2011-02-14 04:47:18 +0000
72@@ -32,6 +32,10 @@
73 '[on|off]',
74 'enables advanced subscriptions features',
75 'off'),
76+ ('malone.disable_targetnamesearch',
77+ '[empty|nonempty]',
78+ 'If nonempty targetnames are not consulted during text search.'
79+ ''),
80 ('memcache',
81 '[enabled|disabled]',
82 'enables/disables memcache',