← Back to team overview

launchpad-reviewers team mailing list archive

[Merge] lp:~stevenk/launchpad/drop-bugtask-flattener into lp:launchpad

 

Steve Kowalik has proposed merging lp:~stevenk/launchpad/drop-bugtask-flattener into lp:launchpad.

Requested reviews:
  Steve Kowalik (stevenk): code

For more details, see:
https://code.launchpad.net/~stevenk/launchpad/drop-bugtask-flattener/+merge/114108

Drop BugTaskFlattener, it's been done for a while. BTF for lyfe
-- 
https://code.launchpad.net/~stevenk/launchpad/drop-bugtask-flattener/+merge/114108
Your team Launchpad code reviewers is subscribed to branch lp:launchpad.
=== modified file 'lib/lp/scripts/garbo.py'
--- lib/lp/scripts/garbo.py	2012-07-05 10:54:35 +0000
+++ lib/lp/scripts/garbo.py	2012-07-10 07:03:21 +0000
@@ -42,7 +42,6 @@
 from lp.bugs.model.bug import Bug
 from lp.bugs.model.bugattachment import BugAttachment
 from lp.bugs.model.bugnotification import BugNotification
-from lp.bugs.model.bugtask import BugTask
 from lp.bugs.model.bugwatch import BugWatchActivity
 from lp.bugs.scripts.checkwatches.scheduler import (
     BugWatchScheduler,
@@ -79,7 +78,6 @@
 from lp.services.librarian.model import TimeLimitedToken
 from lp.services.log.logger import PrefixFilter
 from lp.services.looptuner import TunableLoop
-from lp.services.memcache.interfaces import IMemcacheClient
 from lp.services.oauth.model import OAuthNonce
 from lp.services.openid.model.openidconsumer import OpenIDConsumerNonce
 from lp.services.propertycache import cachedproperty
@@ -992,47 +990,6 @@
         transaction.commit()
 
 
-class BugTaskFlattener(TunableLoop):
-    """A `TunableLoop` to populate BugTaskFlat for all bugtasks."""
-
-    maximum_chunk_size = 5000
-
-    def __init__(self, log, abort_time=None):
-        super(BugTaskFlattener, self).__init__(log, abort_time)
-        generation = getFeatureFlag('bugs.bugtaskflattener.generation')
-        if generation is None:
-            self.start_at = None
-        else:
-            self.memcache_key = (
-                '%s:bugtask-flattener:%s'
-                % (config.instance_name, generation.encode('utf-8')))
-            watermark = getUtility(IMemcacheClient).get(self.memcache_key)
-            self.start_at = watermark or 0
-
-    def findTaskIDs(self):
-        if self.start_at is None:
-            return EmptyResultSet()
-        return IMasterStore(BugTask).find(
-            (BugTask.id,), BugTask.id >= self.start_at).order_by(BugTask.id)
-
-    def isDone(self):
-        return self.findTaskIDs().is_empty()
-
-    def __call__(self, chunk_size):
-        ids = [row[0] for row in self.findTaskIDs()[:chunk_size]]
-        list(IMasterStore(BugTask).using(BugTask).find(
-            SQL('bugtask_flatten(BugTask.id, false)'),
-            BugTask.id.is_in(ids)))
-
-        self.start_at = ids[-1] + 1
-        result = getUtility(IMemcacheClient).set(
-            self.memcache_key, self.start_at)
-        if not result:
-            self.log.warning('Failed to set start_at in memcache.')
-
-        transaction.commit()
-
-
 class BaseDatabaseGarbageCollector(LaunchpadCronScript):
     """Abstract base class to run a collection of TunableLoops."""
     script_name = None  # Script name for locking and database user. Override.
@@ -1286,7 +1243,6 @@
         UnusedSessionPruner,
         DuplicateSessionPruner,
         BugHeatUpdater,
-        BugTaskFlattener,
         ]
     experimental_tunable_loops = []
 

=== modified file 'lib/lp/scripts/tests/test_garbo.py'
--- lib/lp/scripts/tests/test_garbo.py	2012-07-05 10:54:35 +0000
+++ lib/lp/scripts/tests/test_garbo.py	2012-07-10 07:03:21 +0000
@@ -39,7 +39,6 @@
     BugNotification,
     BugNotificationRecipient,
     )
-from lp.bugs.model.bugtask import BugTask
 from lp.code.bzr import (
     BranchFormat,
     RepositoryFormat,
@@ -104,10 +103,7 @@
     TestCase,
     TestCaseWithFactory,
     )
-from lp.testing.dbuser import (
-    dbuser,
-    switch_dbuser,
-    )
+from lp.testing.dbuser import switch_dbuser
 from lp.testing.layers import (
     DatabaseLayer,
     LaunchpadScriptLayer,
@@ -1021,47 +1017,6 @@
         self.runHourly()
         self.assertNotEqual(old_update, naked_bug.heat_last_updated)
 
-    def test_BugTaskFlattener(self):
-        # Bugs without a record in BugTaskFlat get mirrored.
-        # Remove the existing mirrored data.
-        with dbuser('testadmin'):
-            task = self.factory.makeBugTask()
-            IMasterStore(BugTask).execute(
-                'DELETE FROM BugTaskFlat WHERE bugtask = ?', (task.id,))
-
-        def get_flat():
-            return IMasterStore(BugTask).execute(
-                'SELECT bugtask FROM BugTaskFlat WHERE bugtask = ?',
-                (task.id,)).get_one()
-
-        # Nothing is done until the feature flag is set.
-        self.runHourly()
-        self.assertIs(None, get_flat())
-
-        # If we set the generation flag, the bug will be mirrored.
-        with dbuser('testadmin'):
-            IMasterStore(FeatureFlag).add(FeatureFlag(
-                u'default', 0, u'bugs.bugtaskflattener.generation', u'1'))
-        self.runHourly()
-        self.assertEqual((task.id,), get_flat())
-
-        # A watermark is kept in memcache, so a second run doesn't
-        # consider the same task.
-        with dbuser('testadmin'):
-            IMasterStore(BugTask).execute(
-                'DELETE FROM BugTaskFlat WHERE bugtask = ?', (task.id,))
-        self.runHourly()
-        self.assertIs(None, get_flat())
-
-        # Incrementing the generation feature flag causes a fresh pass.
-        with dbuser('testadmin'):
-            IMasterStore(FeatureFlag).find(
-                FeatureFlag, flag=u'bugs.bugtaskflattener.generation').remove()
-            IMasterStore(FeatureFlag).add(FeatureFlag(
-                u'default', 1, u'bugs.bugtaskflattener.generation', u'2'))
-        self.runHourly()
-        self.assertEqual((task.id,), get_flat())
-
 
 class TestGarboTasks(TestCaseWithFactory):
     layer = LaunchpadZopelessLayer

=== modified file 'lib/lp/services/features/flags.py'
--- lib/lp/services/features/flags.py	2012-06-26 10:19:37 +0000
+++ lib/lp/services/features/flags.py	2012-07-10 07:03:21 +0000
@@ -63,14 +63,6 @@
      '',
      '',
      'https://bugs.launchpad.net/launchpad/+bug/678090'),
-    ('bugs.bugtaskflattener.generation',
-     'string',
-     ("Sets the key used to store progress in a BugTaskFlat update pass. "
-      "Normally disabled unless recent schema changes require a full "
-      "update."),
-     'BugTaskFlattener disabled',
-     '',
-     ''),
     ('bugs.bugtracker_components.enabled',
      'boolean',
      ('Enables the display of bugtracker components.'),


Follow ups