CloudKit: record change tag might be updated behind the scenes when sharing is used

I have recently discovered that if a CKRecord is saved with a new parent reference, the parent's change tag might be changed by CloudKit behind the scenes. The client is not notified about this change in any way.


If you rely on the change tag to ensure consistency between your local and remote records, you might have unexpected problems once you start using sharing in CloudKit.


I reported that to Apple (bug report 27396718) and at first they replied that this is an intended behaviour and closed the report. Fortunately, after I provided some arguments to them they re-opened the report and promised to see if there is anything that they can do about it.


If you believe that this issue should be fixed, please create a new bug report at bugreport.apple.com mentioning 27396718 as the original report. Apple is using duplicate reports as a "voting system" to identify issues that should be prioritized. This is the only way for us (developers) to ensure that this gets fixed before it is not too late in terms of iOS 10 development cycle.

Replies

Three weeks later, we are now in beta 6 and the bug is still there 😟

So what happens - you get an error that your change tag is invalid and you then have to merge the changes and attempt the next save again?


In our case at least we already have to handle that error condition so it seems like no big deal... unless I'm missing something?

Well, the change tag is supposed to be updated only if the contents of the record were changed (that is according to the docs). With this bug the contents remain the same but the change tag gets updated anyway.


In my specific case, conflict resolution is based on the idea that the server has always the latest records. If the server has a newer change tag, then whatever the client has should be replaced by the server version. However, because CloudKit might update change tags at completely irrelevant moments (e.g. when child records are created), this creates a problem for method of conflict resolution. When this happens the server suddenly has a newer version and in case of a conflict resolution situation it gets priority when it clearly should not.

Any updates to this issue since beta six?


If you can't rely on change tags for this, have you implemented a different system?

Unfortunately, there are no news, my bug report 27396718 is still open. Please create your own bug report mentioning this number as this is the only way to indicate to Apple that we need to have this fixed.


In my particular case I had to ignore record change tag change when a record was modified within the last 10-15 minutes.

I noticed when the short identifier is enabled it updates the change tag, maybe that's what happened. If you use fetch changes you'll get it though.

Just checking if the situation still exists in iOS11?