I'm having trouble with fetching CloudKit record changes made on another device and merging them into my local database.
When I change a record on device B, I get a zone-change notification from CloudKit on device A (as expected). So I do a CKFetchRecordChangesOperation, and when I get the changed record from CloudKit I hand it to the mergeRecord method of YapDatabaseCloudKitTransaction. My mergeBlock simply takes the remote record's values and saves them to the local database, not touching updatedPendingLocalRecord. Everything seems to work fine, with no errors.
But then the next time device A makes a change to that database object, the CloudKit extension gets a "Server Record Changed" error when it tries to upload the change. This appears to be happening because my local record's recordChangeTag somehow didn't get updated, and is still the same as it was before the last CKFetchRecordChangesOperation.
I'm looking for some kind of lead to begin debugging this. Where and when does the CloudKit extension save the recordChangeTag? What could cause it not save the recordChangeTag of a record that gets handed to mergeRecord?