How do I fix a corrupt calendar cache?
- by Blacklight Shining
I was tailing /var/log/system.log and noticed a sudden wall of text. Looking closer, I saw it was an error CalendarAgent got while trying to save something:
Nov 18 11:42:45 rainbow-dash.local CalendarAgent[12321]: CoreData: error: (11) Fatal error. The database at /Users/blackl/Library/Calendars/Calendar Cache is corrupted. SQLite error code:11, 'database disk image is malformed'
Nov 18 11:42:45 rainbow-dash.local CalendarAgent[12321]: Core Data: annotation: -executeRequest: encountered exception = Fatal error. The database at /Users/blackl/Library/Calendars/Calendar Cache is corrupted. SQLite error code:11, 'database disk image is malformed' with userInfo = {
NSFilePath = "/Users/blackl/Library/Calendars/Calendar Cache";
NSSQLiteErrorDomain = 11;
}
2 messages repeated several times
Nov 18 11:42:49 rainbow-dash.local CalendarAgent[12321]: [com.apple.calendar.store.log.subscription] [WARNING: CalSubscriptionSession :: persistError :: save failed]
This entire sequence is repeated many times throughout the log.
file said the file in question was a SQLite 3.x database, so I did a bit of searching and came up with a way to check those.
blackl% cp -i ~/Library/Calendars/Calendar\ Cache /tmp
blackl% sqlite3 /tmp/Calendar\ Cache
SQLite version 3.7.12 2012-04-03 19:43:07
Enter ".help" for instructions
Enter SQL statements terminated with a ";"
sqlite> pragma integrity_check ;
*** in database main ***
Main freelist: Bad ptr map entry key=863 expected=(2,0) got=(5,21)
On page 21 at right child: 2nd reference to page 863
This is followed by a few dozen lines like these:
rowid <number> missing from index <name>
and then:
wrong # of entries in index <name>
I'm at a bit of a loss as to what to do now—I couldn't find anything on how to fix the errors that I found. Also, it would probably be a good idea to disable Calendar Agent so it doesn't try to use the database while it's being fixed (that's why I copied it to /tmp before running sqlite3 on it.)
How do I disable CalendarAgent and fix its cache?