[CalendarServer-dev] Possible bug in query caching

Kristoffer =?utf-8?Q?M=C3=B8llerh=C3=B8?=j kmo at b-one.net
Mon May 29 05:30:56 PDT 2017


I am testing the script calendarserver/tools/pod_migration.py in a multipod test setup, migrating an account from one pod to another. I get an error message in migration step 5:

CrossPodHomeSync: Starting: sharedByCollectionsReconcile...
CrossPodHomeSync: Found shared by calendar local-id=3, remote-id=12 with 1 sharees
CrossPodHomeSync: Adding new sharee 6
CrossPodHomeSync: Updating remote records
Error: 'NoneType' object has no attribute 'sharingBindRecords'

Please note that the error only happens if the user under migration shares a calendar with another user on same pod.

This has been tested on CalendarServer-9.2-dev.

After a lot of debugging, I found the problem to most likely be caused by a bug in the query caching:

In the function txdav.common.datastore.sql.CommonHome.homeWith, results returned from the cache is not handled completely the same as results obtained from a sql query. At


, the first matching cacheKey is handled as a match, and the loop exited, even though more cacheKeys might match.

However, at


, after a sql query, more than one matches are handled and prioritized, i.e. to return _HOME_STATUS_DISABLED instead of _HOME_STATUS_EXTERNAL if both are present.

I have tested two different solutions that both seems to fix the problem:

1) Disable query caching in the function homeWith

2) Don't exit the loop when first matching cacheKey is found, instead collect list of all matches, and prioritize between them as it is currently done after a sql query.

Best regards,
Kristoffer Møllerhøj,

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/calendarserver-dev/attachments/20170529/9e54344a/attachment.html>

More information about the calendarserver-dev mailing list