[CalendarServer-changes] [8807] CalendarServer/trunk/twistedcaldav/method
source_changes at macosforge.org
source_changes at macosforge.org
Wed Feb 29 19:33:16 PST 2012
Revision: 8807
http://trac.macosforge.org/projects/calendarserver/changeset/8807
Author: cdaboo at apple.com
Date: 2012-02-29 19:33:13 -0800 (Wed, 29 Feb 2012)
Log Message:
-----------
Handle ConcurrentModification exception in more places.
Modified Paths:
--------------
CalendarServer/trunk/twistedcaldav/method/report_addressbook_query.py
CalendarServer/trunk/twistedcaldav/method/report_calendar_query.py
CalendarServer/trunk/twistedcaldav/method/report_sync_collection.py
Modified: CalendarServer/trunk/twistedcaldav/method/report_addressbook_query.py
===================================================================
--- CalendarServer/trunk/twistedcaldav/method/report_addressbook_query.py 2012-02-29 20:26:02 UTC (rev 8806)
+++ CalendarServer/trunk/twistedcaldav/method/report_addressbook_query.py 2012-03-01 03:33:13 UTC (rev 8807)
@@ -1,6 +1,6 @@
# -*- test-case-name: twistedcaldav.test.test_addressbookquery -*-
##
-# Copyright (c) 2006-2010 Apple Inc. All rights reserved.
+# Copyright (c) 2006-2012 Apple Inc. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
@@ -39,6 +39,8 @@
from twistedcaldav.method import report_common
from twistedcaldav.query import addressbookqueryfilter
+from txdav.common.icommondatastore import ConcurrentModification
+
log = Logger()
@inlineCallbacks
@@ -123,6 +125,7 @@
raise NumberOfMatchesWithinLimits(max_number_of_results[0])
+ @inlineCallbacks
def queryAddressBookObjectResource(resource, uri, name, vcard, query_ok = False):
"""
Run a query on the specified vcard.
@@ -141,12 +144,17 @@
else:
href = davxml.HRef.fromString(uri)
- return report_common.responseForHref(request, responses, href, resource, propertiesForResource, query, vcard=vcard)
- else:
- return succeed(None)
+ try:
+ yield report_common.responseForHref(request, responses, href, resource, propertiesForResource, query, vcard=vcard)
+ except ConcurrentModification:
+ # This can happen because of a race-condition between the
+ # time we determine which resources exist and the deletion
+ # of one of these resources in another request. In this
+ # case, we ignore the now missing resource rather
+ # than raise an error for the entire report.
+ log.err("Missing resource during sync: %s" % (href,))
+
-
-
@inlineCallbacks
def queryDirectoryBackedAddressBook(directoryBackedAddressBook, addressBookFilter):
"""
@@ -160,9 +168,16 @@
# Check size of results is within limit
checkMaxResults()
- yield report_common.responseForHref(request, responses, vCardRecord.hRef(), vCardRecord, propertiesForResource, query, vcard=(yield vCardRecord.vCard()))
+ try:
+ yield report_common.responseForHref(request, responses, vCardRecord.hRef(), vCardRecord, propertiesForResource, query, vcard=(yield vCardRecord.vCard()))
+ except ConcurrentModification:
+ # This can happen because of a race-condition between the
+ # time we determine which resources exist and the deletion
+ # of one of these resources in another request. In this
+ # case, we ignore the now missing resource rather
+ # than raise an error for the entire report.
+ log.err("Missing resource during sync: %s" % (vCardRecord.hRef(),))
-
directoryAddressBookLock = None
try:
Modified: CalendarServer/trunk/twistedcaldav/method/report_calendar_query.py
===================================================================
--- CalendarServer/trunk/twistedcaldav/method/report_calendar_query.py 2012-02-29 20:26:02 UTC (rev 8806)
+++ CalendarServer/trunk/twistedcaldav/method/report_calendar_query.py 2012-03-01 03:33:13 UTC (rev 8807)
@@ -1,5 +1,5 @@
##
-# Copyright (c) 2006-2010 Apple Inc. All rights reserved.
+# Copyright (c) 2006-2012 Apple Inc. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
@@ -34,7 +34,8 @@
from twistedcaldav.caldavxml import caldav_namespace, MaxInstances
from twistedcaldav.config import config
-from txdav.common.icommondatastore import IndexedSearchException
+from txdav.common.icommondatastore import IndexedSearchException,\
+ ConcurrentModification
from twistedcaldav.instance import TooManyInstancesError
from twistedcaldav.method import report_common
from twistedcaldav.query import calendarqueryfilter
@@ -126,6 +127,7 @@
@param uri: the uri for the calendar collection resource.
"""
+ @inlineCallbacks
def queryCalendarObjectResource(resource, uri, name, calendar, timezone, query_ok=False, isowner=True):
"""
Run a query on the specified calendar.
@@ -152,9 +154,15 @@
else:
href = davxml.HRef.fromString(uri)
- return report_common.responseForHref(request, responses, href, resource, propertiesForResource, props, isowner, calendar=calendar, timezone=timezone)
- else:
- return succeed(None)
+ try:
+ yield report_common.responseForHref(request, responses, href, resource, propertiesForResource, props, isowner, calendar=calendar, timezone=timezone)
+ except ConcurrentModification:
+ # This can happen because of a race-condition between the
+ # time we determine which resources exist and the deletion
+ # of one of these resources in another request. In this
+ # case, we ignore the now missing resource rather
+ # than raise an error for the entire report.
+ log.err("Missing resource during query: %s" % (href,))
# Check whether supplied resource is a calendar or a calendar object resource
if calresource.isPseudoCalendarCollection():
Modified: CalendarServer/trunk/twistedcaldav/method/report_sync_collection.py
===================================================================
--- CalendarServer/trunk/twistedcaldav/method/report_sync_collection.py 2012-02-29 20:26:02 UTC (rev 8806)
+++ CalendarServer/trunk/twistedcaldav/method/report_sync_collection.py 2012-03-01 03:33:13 UTC (rev 8807)
@@ -38,6 +38,8 @@
from twistedcaldav.config import config
+from txdav.common.icommondatastore import ConcurrentModification
+
import functools
log = Logger()
@@ -136,23 +138,39 @@
for child, child_uri in ok_resources:
href = davxml.HRef.fromString(child_uri)
- yield responseForHref(
- request,
- responses,
- href,
- child,
- functools.partial(_namedPropertiesForResource, forbidden=False) if propertyreq else None,
- propertyreq)
+ try:
+ yield responseForHref(
+ request,
+ responses,
+ href,
+ child,
+ functools.partial(_namedPropertiesForResource, forbidden=False) if propertyreq else None,
+ propertyreq)
+ except ConcurrentModification:
+ # This can happen because of a race-condition between the
+ # time we determine which resources exist and the deletion
+ # of one of these resources in another request. In this
+ # case, we ignore the now missing resource rather
+ # than raise an error for the entire report.
+ log.err("Missing resource during sync: %s" % (href,))
for child, child_uri in forbidden_resources:
href = davxml.HRef.fromString(child_uri)
- yield responseForHref(
- request,
- responses,
- href,
- child,
- functools.partial(_namedPropertiesForResource, forbidden=True) if propertyreq else None,
- propertyreq)
+ try:
+ yield responseForHref(
+ request,
+ responses,
+ href,
+ child,
+ functools.partial(_namedPropertiesForResource, forbidden=True) if propertyreq else None,
+ propertyreq)
+ except ConcurrentModification:
+ # This can happen because of a race-condition between the
+ # time we determine which resources exist and the deletion
+ # of one of these resources in another request. In this
+ # case, we ignore the now missing resource rather
+ # than raise an error for the entire report.
+ log.err("Missing resource during sync: %s" % (href,))
for name in removed:
href = davxml.HRef.fromString(joinURL(request.uri, name))
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20120229/955d4bce/attachment.html>
More information about the calendarserver-changes
mailing list