[CalendarServer-changes] [12736] CalendarServer/trunk/txdav/common/datastore/work/inbox_cleanup.py

source_changes at macosforge.org source_changes at macosforge.org
Wed Mar 12 11:16:07 PDT 2014


Revision: 12736
          http://trac.calendarserver.org//changeset/12736
Author:   gaya at apple.com
Date:     2014-02-20 12:28:50 -0800 (Thu, 20 Feb 2014)
Log Message:
-----------
InboxCleanupWork.doWork() does not enqueue more CleanupOneInboxWork if CLEANUP_ONE_INBOX_WORK rows are present. CleanupOneInboxWork.doWork() no longer does useless Delete of CLEANUP_ONE_INBOX_WORK rows with same homeID.

Modified Paths:
--------------
    CalendarServer/trunk/txdav/common/datastore/work/inbox_cleanup.py

Modified: CalendarServer/trunk/txdav/common/datastore/work/inbox_cleanup.py
===================================================================
--- CalendarServer/trunk/txdav/common/datastore/work/inbox_cleanup.py	2014-02-20 19:55:55 UTC (rev 12735)
+++ CalendarServer/trunk/txdav/common/datastore/work/inbox_cleanup.py	2014-02-20 20:28:50 UTC (rev 12736)
@@ -51,16 +51,24 @@
         # Delete all other work items
         yield Delete(From=self.table, Where=None).on(self.transaction)
 
-        # enumerate provisioned normal calendar homes
-        ch = schema.CALENDAR_HOME
-        homeRows = yield Select(
-            [ch.RESOURCE_ID],
-            From=ch,
-            Where=ch.STATUS == _HOME_STATUS_NORMAL,
-        ).on(self.transaction)
+        # exit if not done with last delete:
+        coiw = schema.CLEANUP_ONE_INBOX_WORK
+        rows = yield Select([coiw.HOME_ID], From=coiw,).on(self.transaction)
+        if rows:
+            homeIDs = [row[0] for row in rows]
+            log.error("Inbox cleanup work: Can't schedule per-home cleanup because work items still queued for homeIDs: {}".format(
+                homeIDs))
+        else:
+            # enumerate provisioned normal calendar homes
+            ch = schema.CALENDAR_HOME
+            homeRows = yield Select(
+                [ch.RESOURCE_ID],
+                From=ch,
+                Where=ch.STATUS == _HOME_STATUS_NORMAL,
+            ).on(self.transaction)
 
-        for homeRow in homeRows:
-            yield CleanupOneInboxWork._schedule(self.transaction, homeID=homeRow[0], seconds=0)
+            for homeRow in homeRows:
+                yield CleanupOneInboxWork._schedule(self.transaction, homeID=homeRow[0], seconds=0)
 
         # Schedule next check
         yield self._schedule(
@@ -88,10 +96,7 @@
     @inlineCallbacks
     def doWork(self):
 
-        # Delete all other work items for this group (for this home ID)
-        yield Delete(From=self.table,
-            Where=self.table.HOME_ID == self.homeID
-            ).on(self.transaction)
+        # No need to delete other work items.  They are unique
 
         # get orphan names
         orphanNames = set((
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20140312/b2093bb6/attachment.html>


More information about the calendarserver-changes mailing list