YapDatabase
YapDatabase copied to clipboard
Limitation for number of changes per one change request in CloudKit extension
Ability to set the limit for number of changes per one change request in YapDatabaseCloudKitOptions. This can be used to fix "Invalid Arguments" (12/1020); "Your request contains more than the maximum number of items in a single request (400)" error. Discussion in #212.
We were running into the same issue and have been using this patch for several years in production. Would be great to get this merged. 👍
@robbiehanson Can you weigh in on this, please? Maybe I'm misunderstanding #212, but it sounds like if this issue is encountered when registering the extension there is no way around the problem and CloudKit syncing is effectively broken without a change like the one in this PR. Is that correct?
The "max of 400" problem can be encountered in multiple scenarios:
- when registering the extension, and populating it with a large number of items
- when importing a large number of items within a single transaction
This PR limits the maximum number of changes that can be pushed to the cloud in a single request. This would seem to solve the issue. However, I haven't merged this pull request because, as I understand it, the PR does its limitation in an "arbitrary" manner. Whereby "arbitrary", I mean that it doesn't take into account CKReferences.
I suggested in #212 :
Fix the internals of YapDatabaseCloudKit to automatically split a ChangeSet into a maximum of 400 items. And do so in a safe way that allows us to take into consideration CKReferences.
So if A has a CKReference to B, and the ChangeSet is split like so: [..., A] [B, ...]
, we're going to get an error from the server. Its been awhile since I've worked with CloudKit, so let me know if I'm off on this.
@robbiehanson Thanks for your input. Your description is correct. I have an idea for addressing that problem so I'll look into it soon.