Experience with CKSyncEngine in the Forked library #358
Replies: 3 comments 2 replies
-
|
Thanks @drewmccormack for sharing your insights. They felt relevant for the wider Point-Free community, which is why I’ve reposted your comment here. I don’t yet have production experience with Looks like you have real-world experience with |
Beta Was this translation helpful? Give feedback.
-
|
The types of issues that can arise are that if you get edits out of order, you could lose data. So it is pretty serious. What I suspect, but haven't got proof for (I should try to make some), is that CKSyncEngine will not always give you an error when you are committing a record that is not predicated on the latest version from the server. This is essential, because it forms the basis of the optimistic locking which guarantees data consistency. You need to know that when you commit changes to a record, it will fail to upload should there be a more recent record on the server. It seems like there may be some race which can arise where it is possible to do this without error. I really should see if I can come up with a simple test to prove this problem and submit it to apple. |
Beta Was this translation helpful? Give feedback.
-
|
The way I usually do it, and I think is quite standard with any sync system, is to fetch the latest record, update the record, and upload the record. If it fails because the record on the server changed in the meantime, you do it all over again. So I always work with the most recent record, applying the local changes on top of those, and attempting the upload. If it does decide to fetch new changes while I'm in the middle of this, I would hope it would give me an error when I try to commit my new changes. But maybe it is what you are saying: it doesn't consider that a conflict or something. Maybe you are supposed to do your own optimistic locking, by copying the token when you start the op, and check the token just before committing. That would still be pretty silly, I think, because again, it would be wide open to races. The only code that can properly detect concurrent updates is the code that uploads, namely CKSyncEngine itself. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
This is a continuation of the discussion originally started by @drewmccormack in #354 (comment).
Beta Was this translation helpful? Give feedback.
All reactions