Q: Calendar hang for one user
Hi!
I have OS Server 4.1 running successfully, with 20 odd clients with Calendar Server running without problems. However, one user (me as it happens) has what must be a corrupt (in some way) calendar. If I try to connect, or use the WebCal, It hangs (in WebCal it just sits there spinning loading events, on Calendar it just says it can't connect after a timeout). In the logs I can see many lines of:
2015-07-03 22:45:48+1000 [-] [caldav-3] [-] [txdav.common.datastore.sql#error] Transaction abort too long: PG-TXN<<PROPFIND /calendars/__uids__/556D3E30-6FF9-4681-9985-78F192BD591A/ (1, 1)>>, Statements: 12, IUDs: 0, Statement: None
Now, I don’t know how or why this has suddenly happened, but I’m quite happy to wipe that calendar completely and re-import the backup I have. I just don’t know how to wipe it without killing the 20 odd working ones (and having the entire company get angry).
I can’t connect at all with Calendar, as it sits there and eventually times out. So I can’t get in and delete calendar events.
As I said, everyone else is fine. Just my calendar.
Does anyone know of any way to wipe a calendar for just one user, but not hurt any others?
Any help appreciated.
Mac Pro, OS X Yosemite (10.10.3)
Posted on Jul 4, 2015 10:26 PM
Ok, one of the Software Engineers at Apple sent me the solution (I don't know if he wants me to put his name here, so I won't). Anyway, he told me to basically do:
You can nuke a user and all that user's calendars and events using the calendarserver_purge_principals tool.
Something like this:
sudo calendarserver_purge_principals -v user01
Keep in mind that calendar data often belongs to more than one user. For example, running the above commands will delete not only user01's calendars, but also any events that user01 has created which others may be attending. Other attendees will see cancellation notices for those events.
Now, we wanted to avoid the notification spams, so we came up with a much hackier solution, that ends up doing what was suggested, after some manual cleanup, to avoid the notifications going out.
What we discovered is that we were able to delete the events directly from the calendar database, which DID NOT send any cancellation notices to any, but didn’t seem to completely clean up the calendars either. However, we then discovered that running the ‘purge’ command after manually deleting the events finished the clean up, and did not trigger any cancellation notices either!
So the steps to fix it were:
1. Get the list of users and their UUIDs to find the one you want to delete:
sudo calendarserver_manage_principals --list-principals users
2. Connect to the calendar server database (as root):
psql -h /var/run/caldavd/PostgresSocket -U caldav caldav
3. Run this query, substituting the UUID:
DELETE FROM calendar_object
WHERE calendar_object.calendar_resource_id IN (
SELECT calendar_bind.calendar_resource_id
FROM
calendar_bind
JOIN calendar_home ON calendar_home.resource_id = calendar_bind.calendar_home_resource_id
WHERE calendar_home.owner_uid = '556D3E30-6FF9-4681-9985-78F192BD591A'
);
4. Run the purge command, substituting the UUID:
sudo calendarserver_purge_principals -v 556D3E30-6FF9-4681-9985-78F192BD591A
This leaves you without a calendar, so you have to then create a new one, or get someone to invite you to an event, so the system creates one for you.
And hopefully this comes in handy for someone looking for a solution for a similar problem.
Posted on Jul 10, 2015 1:10 AM