Cloudd quit unexpectedly

Ever since I upgraded to Yosemite, I have been experiencing cloudd quit unexpectedly bug reports popping up at front very very often.

The issue is :

Crashed Thread:        0  Dispatch queue: com.apple.main-thread

Exception Type:        EXC_CRASH (SIGABRT)
Exception Codes:       0x0000000000000000, 0x0000000000000000

Application Specific Information:
*** Terminating app due to uncaught exception 'NSGenericException', reason: 'Error opening db at /Users/peter/Library/Caches/CloudKit/CloudKitMetadata: <CKError 0x7f8bc1419590: "Internal Error" (1)> (14/0x000e/unable to open database file)'
terminating with uncaught exception of type NSException
abort() called


Application Specific Backtrace 1:
0   CoreFoundation                      0x00007fff88a6464c __exceptionPreprocess + 172
1   libobjc.A.dylib                     0x00007fff89b036de objc_exception_throw + 43
2   CoreFoundation                      0x00007fff88a644fd +[NSException raise:format:] + 205
3   CloudKit                            0x00007fff83448a47 -[CKSQLite raise:] + 516
4   CloudKit                            0x00007fff834483b6 -[CKSQLite open] + 122
5   CloudKitDaemon                      0x000000010b523481 -[CKDMetadataCache init] + 199
6   CloudKitDaemon                      0x000000010b5233a0 __31+[CKDMetadataCache sharedCache]_block_invoke + 41
7   libdispatch.dylib                   0x00007fff88e1fc13 _dispatch_client_callout + 8
8   libdispatch.dylib                   0x00007fff88e1fb26 dispatch_once_f + 117
9   CloudKitDaemon                      0x000000010b523375 +[CKDMetadataCache sharedCache] + 46
10  cloudd                              0x000000010b37e541 cloudd + 5441
11  cloudd                              0x000000010b37e0e0 cloudd + 4320
12  cloudd                              0x000000010b37eace cloudd + 6862
13  libdyld.dylib                       0x00007fff85ebf5c9 start + 1

I do not know if this is relevant, but during 10.9 to 10.10 (yosemite) upgrade, I was asked to log in with my apple ID. I was connected to a WIFI provider (but not logged in) so I wasn't able to log in. The update did continue. On the first session I opened, iCloud kept crashing. I had a really hard time disabling iCloud drive.


The exception message says:

Error opening db at /Users/peter/Library/Caches/CloudKit/CloudKitMetadata

Make sure that cloudd has permissions to write in that directory. If the directories permissions are fine, maybe the db was corrupted during the update. Try to move the file somewhere else, it's possible cloudd will recreate it if it doesn't see it.