Deleted CloudKit records Reappear

I'm building an iOS application using CloudKit.

It should allow a user to add, edit and delete

Products
in the cloud. The user can organize these in Folders.

These folders are just other Record Types in cloudkit. There is no limit to the levels of folder the user can use, as any folder can just hold a

CKReference
to it's parent Folder.


All CloudKit communication in my app happens in a dedicated, custom CloudKitController Class.


This all works, but stops working after a while for no clear reason.

When I test my app, I don't even user folders that are multiple levels deep. However, after testing it a while (creating, editing, deleting products for up to a week), All deleted records seem to reappear on CloudKit. A couple of notes on this:

  • When I reset my CloudKit dashboard and start all over again, it works perfect. No code changes made.
  • Obviously, I'm constantly editing my code as the app is in development. However, I generally don't edit the data types in my code that are to be stored in CloudKit. When I do, this issue does not arise straigt afterwards so that doesn't cause it.
  • Changes in the CloudKit Dashboard (e.g. adding data types) do not cause this issue either
  • Am not storing any records locally, like in CoreData. They just sit in a singleton as long as I use them
  • When I go to CloudKit Dashboard, the Product Record Type shows it has e.g. 13 instances. Sometimes it's so bad, that my app actually loads over 100. I can also see them when I go to the recordZone, but still the RecordType says it only has 13 instances
  • Deleting these records in CloudKit Dashboard only makes them disappear for a while. When I reload the page, they pop up again.

It has been going like this for a while now, and I have checked my code, the Apple Library and google numerous of times but I cannot figure out what causes this issue.


Question: Would anyone know anything on how to overcome this issue? As I said, I've been running into this for weeks, and resetting my CloudKit dashboard only 'cures' it for up to a week, then it pops up again. I'd also be more than happy to post any code if that would help you answer my question. I haven't posted any code initially, as I have no clue what code might cause this.

Any answer would be highly appreciated

No help but I have a similar problem. I delete records from the public container in cloudKit using the Dashboard and they reappear.

It would be very helpful if you could please file a radar on this issue. Please go to https://bugreport.apple.com

I have already filed a bug report. Also, I have a stackoverflow thread for it: http://stackoverflow.com/questions/30950081/deleted-cloudkit-records-reappear.

If any other action is needed to fix this issue, please let me know. Thanks for the reply so far.

Am also having the same issue. Once I delete the records they start to reappear even after resetting the development environment. If anyone finds a solution or a cause do let know.

It seems records are not deletable -- deleting all record types in dashboard does not change database and asset storage. Surprisingly it doesn't break apps based on CloudKit, such as Notes.

It takes a long time to delete records, although the dashboard shows them deleted instantly they are actually deleted one-by-one with a roundtrip to the server for each which can be seen in Safari using the error console on the network tab. In this video you can see it takes over a minute to delete the 81 records. Navigating away from this page would have cancelled the delete and then the records would re-appear because they weren't fully deleted. This is likely the problem you are appearing. I believe they either need a batch delete or at least only remove the record from the list once it is really deleted so people know not to leave the page until they are all gone, or even simpler an activity indicator showing that the operation is in progress.

I have the same issue with deleting records from the dashboard manually and then when I query the data from the app, they just reappear again. These are private database records.

If someone knows how to fix it, please post a solution. Thanks.

The solution is to wait until they are really deleted, use Safari->Develop->Web Inspector, Network tab and wait until the deletes finish before changing pages. The Dashboard has a bad design of its networking calls but I'm sure they will be working fixing these problems. E.g. they will batch deletes into one call rather than individual ones. It was probably low on their priority list to do the dashboard properly.

I was wondering if they are kept so the system knows they are _supposed_ to be deleted? Sample Cloudkit code I have seen typically replays the creation and deletion of ALL objects up to the present state, so maybe thats why they are kept.


I am trying to instead download all data from Cloudkit, get a token for the current state, and just continue synchronising from there- but my code isn't reliable yet. (it is, for me, but not for others that are testing it)

Deleted CloudKit records Reappear
 
 
Q