[CalendarServer-changes] [13199] CalendarServer/trunk

source_changes at macosforge.org source_changes at macosforge.org
Tue Apr 8 12:42:45 PDT 2014


Revision: 13199
          http://trac.calendarserver.org//changeset/13199
Author:   cdaboo at apple.com
Date:     2014-04-08 12:42:44 -0700 (Tue, 08 Apr 2014)
Log Message:
-----------
Automatically create a txn label from previous caller's frame rather than raise an assertion.

Modified Paths:
--------------
    CalendarServer/trunk/calendarserver/push/applepush.py
    CalendarServer/trunk/txdav/caldav/datastore/scheduling/imip/inbound.py
    CalendarServer/trunk/txdav/caldav/datastore/sql.py
    CalendarServer/trunk/txdav/common/datastore/sql.py
    CalendarServer/trunk/txdav/common/datastore/upgrade/migrate.py
    CalendarServer/trunk/txdav/common/datastore/upgrade/sql/upgrade.py
    CalendarServer/trunk/txdav/common/datastore/upgrade/sql/upgrades/addressbook_upgrade_from_1_to_2.py
    CalendarServer/trunk/txdav/common/datastore/upgrade/sql/upgrades/calendar_upgrade_from_1_to_2.py
    CalendarServer/trunk/txdav/common/datastore/upgrade/sql/upgrades/calendar_upgrade_from_3_to_4.py
    CalendarServer/trunk/txdav/common/datastore/upgrade/sql/upgrades/calendar_upgrade_from_4_to_5.py
    CalendarServer/trunk/txdav/common/datastore/upgrade/sql/upgrades/calendar_upgrade_from_5_to_6.py

Modified: CalendarServer/trunk/calendarserver/push/applepush.py
===================================================================
--- CalendarServer/trunk/calendarserver/push/applepush.py	2014-04-08 18:01:59 UTC (rev 13198)
+++ CalendarServer/trunk/calendarserver/push/applepush.py	2014-04-08 19:42:44 UTC (rev 13199)
@@ -182,7 +182,7 @@
         @type purgeSeconds: C{int}
         """
         self.log.debug("ApplePushNotifierService purgeOldSubscriptions")
-        txn = self.store.newTransaction()
+        txn = self.store.newTransaction(label="ApplePushNotifierService.purgeOldSubscriptions")
         yield txn.purgeOldAPNSubscriptions(int(time.time()) - purgeSeconds)
         yield txn.commit()
 
@@ -338,7 +338,7 @@
             if token is not None:
                 self.log.debug("Removing subscriptions for bad token: %s" %
                     (token,))
-                txn = self.factory.store.newTransaction()
+                txn = self.factory.store.newTransaction(label="APNProviderProtocol.processError")
                 subscriptions = (yield txn.apnSubscriptionsByToken(token))
                 for key, _ignore_modified, _ignore_uid in subscriptions:
                     self.log.debug("Removing subscription: %s %s" %
@@ -721,7 +721,7 @@
 
         self.log.debug("FeedbackProtocol processFeedback time=%d token=%s" %
             (timestamp, token))
-        txn = self.factory.store.newTransaction()
+        txn = self.factory.store.newTransaction(label="APNFeedbackProtocol.processFeedback")
         subscriptions = (yield txn.apnSubscriptionsByToken(token))
 
         for key, modified, _ignore_uid in subscriptions:
@@ -947,7 +947,7 @@
         @type key: C{str}
         """
         now = int(time.time()) # epoch seconds
-        txn = self.store.newTransaction()
+        txn = self.store.newTransaction(label="APNSubscriptionResource.addSubscription")
         yield txn.addAPNSubscription(token, key, now, uid, userAgent, host)
         yield txn.commit()
 

Modified: CalendarServer/trunk/txdav/caldav/datastore/scheduling/imip/inbound.py
===================================================================
--- CalendarServer/trunk/txdav/caldav/datastore/scheduling/imip/inbound.py	2014-04-08 18:01:59 UTC (rev 13198)
+++ CalendarServer/trunk/txdav/caldav/datastore/scheduling/imip/inbound.py	2014-04-08 19:42:44 UTC (rev 13199)
@@ -169,7 +169,7 @@
 
 @inlineCallbacks
 def scheduleNextMailPoll(store, seconds):
-    txn = store.newTransaction()
+    txn = store.newTransaction(label="scheduleNextMailPoll")
     notBefore = datetime.datetime.utcnow() + datetime.timedelta(seconds=seconds)
     log.debug("Scheduling next mail poll: %s" % (notBefore,))
     yield txn.enqueue(IMIPPollingWork, notBefore=notBefore)
@@ -252,7 +252,7 @@
             log.error("Mail gateway can't find token in DSN %s" % (msgId,))
             return
 
-        txn = self.store.newTransaction()
+        txn = self.store.newTransaction(label="MailReceiver.processDSN")
         result = (yield txn.imipLookupByToken(token))
         yield txn.commit()
         try:
@@ -278,7 +278,7 @@
             pass
 
         log.warn("Mail gateway processing DSN %s" % (msgId,))
-        txn = self.store.newTransaction()
+        txn = self.store.newTransaction(label="MailReceiver.processDSN")
         yield txn.enqueue(IMIPReplyWork, organizer=organizer, attendee=attendee,
             icalendarText=str(calendar))
         yield txn.commit()
@@ -301,7 +301,7 @@
                            "message %s" % (msg['To'], msg['Message-ID']))
             returnValue(self.MALFORMED_TO_ADDRESS)
 
-        txn = self.store.newTransaction()
+        txn = self.store.newTransaction(label="MailReceiver.processReply")
         result = (yield txn.imipLookupByToken(token))
         yield txn.commit()
         try:
@@ -387,7 +387,7 @@
             # the appropriate ATTENDEE.  This will require a new localizable
             # email template for the message.
 
-        txn = self.store.newTransaction()
+        txn = self.store.newTransaction(label="MailReceiver.processReply")
         yield txn.enqueue(IMIPReplyWork, organizer=organizer, attendee=attendee,
             icalendarText=str(calendar))
         yield txn.commit()

Modified: CalendarServer/trunk/txdav/caldav/datastore/sql.py
===================================================================
--- CalendarServer/trunk/txdav/caldav/datastore/sql.py	2014-04-08 18:01:59 UTC (rev 13198)
+++ CalendarServer/trunk/txdav/caldav/datastore/sql.py	2014-04-08 19:42:44 UTC (rev 13199)
@@ -1523,7 +1523,7 @@
         # Use a new transaction to do this update quickly without locking the row for too long. However, the original
         # transaction may have the row locked, so use wait=False and if that fails, fall back to using the original txn.
 
-        newTxn = obj.transaction().store().newTransaction()
+        newTxn = obj.transaction().store().newTransaction(label="Calendar.reExpandResource")
         try:
             yield obj.lock(wait=False, txn=newTxn)
         except NoSuchObjectResourceError:
@@ -3739,7 +3739,7 @@
 
         # Can only do if cached data exists
         if self._cachedComponent:
-            txn = self.transaction().store().newTransaction("Timeout checkSplit")
+            txn = self.transaction().store().newTransaction(label="Timeout checkSplit")
             yield self.checkSplit(txn=txn)
             yield txn.commit()
 

Modified: CalendarServer/trunk/txdav/common/datastore/sql.py
===================================================================
--- CalendarServer/trunk/txdav/common/datastore/sql.py	2014-04-08 18:01:59 UTC (rev 13198)
+++ CalendarServer/trunk/txdav/common/datastore/sql.py	2014-04-08 19:42:44 UTC (rev 13199)
@@ -88,6 +88,7 @@
 
 from collections import namedtuple
 import datetime
+import inspect
 import itertools
 import json
 import sys
@@ -505,7 +506,8 @@
         authz_uid=None,
     ):
         if label == "unlabeled" or not label:
-            raise AssertionError("Please make sure your transactions have a proper label")
+            tr = inspect.getframeinfo(inspect.currentframe().f_back.f_back)
+            label = "{}#{}${}".format(tr.filename, tr.lineno, tr.function)
 
         self._store = store
         self._calendarHomes = {}

Modified: CalendarServer/trunk/txdav/common/datastore/upgrade/migrate.py
===================================================================
--- CalendarServer/trunk/txdav/common/datastore/upgrade/migrate.py	2014-04-08 18:01:59 UTC (rev 13198)
+++ CalendarServer/trunk/txdav/common/datastore/upgrade/migrate.py	2014-04-08 19:42:44 UTC (rev 13199)
@@ -217,7 +217,7 @@
         Upgrade one calendar home.
         """
         _ignore_migrateFunc, destFunc = homeTypeLookup[homeType]
-        fileTxn = self.upgrader.fileStore.newTransaction()
+        fileTxn = self.upgrader.fileStore.newTransaction(label="UpgradeHelperProcess.oneUpgrade")
         return (
             maybeDeferred(destFunc(fileTxn), uid)
             .addCallback(
@@ -315,7 +315,7 @@
         uid = normalizeUUIDOrNot(fileHome.uid())
         self.log.warn("Starting migration transaction %s UID %r" %
                       (homeType, uid))
-        sqlTxn = self.sqlStore.newTransaction()
+        sqlTxn = self.sqlStore.newTransaction(label="UpgradeToDatabaseStep.migrateOneHome")
         homeGetter = destFunc(sqlTxn)
         sqlHome = yield homeGetter(uid, create=False)
         if sqlHome is not None and not self.merge:
@@ -409,7 +409,7 @@
 
         # First force each home to v1 data format so the upgrades will be triggered
         self.log.warn("Migration extra steps.")
-        txn = self.sqlStore.newTransaction()
+        txn = self.sqlStore.newTransaction(label="UpgradeToDatabaseStep.doDataUpgradeSteps")
         for storeType in (ECALENDARTYPE, EADDRESSBOOKTYPE):
             schema = txn._homeClass[storeType]._homeSchema
             yield Update(

Modified: CalendarServer/trunk/txdav/common/datastore/upgrade/sql/upgrade.py
===================================================================
--- CalendarServer/trunk/txdav/common/datastore/upgrade/sql/upgrade.py	2014-04-08 18:01:59 UTC (rev 13198)
+++ CalendarServer/trunk/txdav/common/datastore/upgrade/sql/upgrade.py	2014-04-08 19:42:44 UTC (rev 13199)
@@ -313,7 +313,7 @@
         Apply the schema upgrade .sql file to the database.
         """
         self.log.warn("Applying schema upgrade: %s" % (fp.basename(),))
-        sqlTxn = self.sqlStore.newTransaction()
+        sqlTxn = self.sqlStore.newTransaction(label="UpgradeDatabaseSchemaStep.applyUpgrade")
         try:
             sql = fp.getContent()
             yield sqlTxn.execSQLBlock(sql)

Modified: CalendarServer/trunk/txdav/common/datastore/upgrade/sql/upgrades/addressbook_upgrade_from_1_to_2.py
===================================================================
--- CalendarServer/trunk/txdav/common/datastore/upgrade/sql/upgrades/addressbook_upgrade_from_1_to_2.py	2014-04-08 18:01:59 UTC (rev 13198)
+++ CalendarServer/trunk/txdav/common/datastore/upgrade/sql/upgrades/addressbook_upgrade_from_1_to_2.py	2014-04-08 19:42:44 UTC (rev 13199)
@@ -85,7 +85,7 @@
 def removeResourceType(sqlStore):
     logUpgradeStatus("Starting Addressbook Remove Resource Type")
 
-    sqlTxn = sqlStore.newTransaction()
+    sqlTxn = sqlStore.newTransaction(label="addressbook_upgrade_from_1_to_2.removeResourceType")
     yield removeProperty(sqlTxn, PropertyName.fromElement(element.ResourceType))
     yield sqlTxn.commit()
     yield cleanPropertyStore()

Modified: CalendarServer/trunk/txdav/common/datastore/upgrade/sql/upgrades/calendar_upgrade_from_1_to_2.py
===================================================================
--- CalendarServer/trunk/txdav/common/datastore/upgrade/sql/upgrades/calendar_upgrade_from_1_to_2.py	2014-04-08 18:01:59 UTC (rev 13198)
+++ CalendarServer/trunk/txdav/common/datastore/upgrade/sql/upgrades/calendar_upgrade_from_1_to_2.py	2014-04-08 19:42:44 UTC (rev 13199)
@@ -56,7 +56,7 @@
 
     logUpgradeStatus("Starting Move supported-component-set")
 
-    sqlTxn = sqlStore.newTransaction()
+    sqlTxn = sqlStore.newTransaction(label="calendar_upgrade_from_1_to_2.moveSupportedComponentSetProperties")
     try:
         # Do not move the properties if migrating, as migration will do a split and set supported-components,
         # however we still need to remove the old properties.

Modified: CalendarServer/trunk/txdav/common/datastore/upgrade/sql/upgrades/calendar_upgrade_from_3_to_4.py
===================================================================
--- CalendarServer/trunk/txdav/common/datastore/upgrade/sql/upgrades/calendar_upgrade_from_3_to_4.py	2014-04-08 18:01:59 UTC (rev 13198)
+++ CalendarServer/trunk/txdav/common/datastore/upgrade/sql/upgrades/calendar_upgrade_from_3_to_4.py	2014-04-08 19:42:44 UTC (rev 13199)
@@ -212,7 +212,7 @@
 def removeResourceType(sqlStore):
     logUpgradeStatus("Starting Calendar Remove Resource Type")
 
-    sqlTxn = sqlStore.newTransaction()
+    sqlTxn = sqlStore.newTransaction(label="calendar_upgrade_from_3_to_4.removeResourceType")
     yield removeProperty(sqlTxn, PropertyName.fromElement(element.ResourceType))
     yield sqlTxn.commit()
     yield cleanPropertyStore()

Modified: CalendarServer/trunk/txdav/common/datastore/upgrade/sql/upgrades/calendar_upgrade_from_4_to_5.py
===================================================================
--- CalendarServer/trunk/txdav/common/datastore/upgrade/sql/upgrades/calendar_upgrade_from_4_to_5.py	2014-04-08 18:01:59 UTC (rev 13198)
+++ CalendarServer/trunk/txdav/common/datastore/upgrade/sql/upgrades/calendar_upgrade_from_4_to_5.py	2014-04-08 19:42:44 UTC (rev 13199)
@@ -129,7 +129,7 @@
     """
     logUpgradeStatus("Starting Calendar Remove Other Properties")
 
-    sqlTxn = sqlStore.newTransaction()
+    sqlTxn = sqlStore.newTransaction(label="calendar_upgrade_from_4_to_5.removeOtherProperties")
 
     yield removeProperty(sqlTxn, PropertyName.fromElement(element.ACL))
     yield removeProperty(sqlTxn, PropertyName.fromElement(element.GETContentType))

Modified: CalendarServer/trunk/txdav/common/datastore/upgrade/sql/upgrades/calendar_upgrade_from_5_to_6.py
===================================================================
--- CalendarServer/trunk/txdav/common/datastore/upgrade/sql/upgrades/calendar_upgrade_from_5_to_6.py	2014-04-08 18:01:59 UTC (rev 13198)
+++ CalendarServer/trunk/txdav/common/datastore/upgrade/sql/upgrades/calendar_upgrade_from_5_to_6.py	2014-04-08 19:42:44 UTC (rev 13199)
@@ -36,7 +36,7 @@
     Do the required upgrade steps.
     """
 
-    sqlTxn = sqlStore.newTransaction()
+    sqlTxn = sqlStore.newTransaction(label="calendar_upgrade_from_5_to_6.doUpgrade")
     cb = schema.CALENDAR_BIND
 
     # Fix shared calendar alarms which should default to "empty"
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20140408/19084287/attachment-0001.html>


More information about the calendarserver-changes mailing list