NSPersistentCloudKitContainer - CloudKit Error 503 after inserting batch of elements

When I sync my large Core Data database with NSPersistentCloudKitContainer, inserting new rows works well for up to 10k rows. (in batches of ~400 inserts)

After that, CloudKit receives a 503 Service Unavailable error with a timeout. Here's the log:

Code Block swift
CoreData: CloudKit: CoreData+CloudKit: -[PFCloudKitExporter exportIfNecessary]_block_invoke_2(153): <PFCloudKitExporter: 0x286124050>: Found 22161 objects needing export.
2021-01-14 11:26:54.985447+0100 [1299:350390] [error] error: CoreData+CloudKit: -[NSCloudKitMirroringDelegate _exportFinishedWithResult:exporter:](1163): <PFCloudKitExporter: 0x286124050>: Export failed with error:
<CKError 0x280ef5a40: "Service Unavailable" (6/2022); "Request failed with http status code 503"; Retry after 185.0 seconds>


The API documentation says 503 means interal server error (try again later) and also says that for throttling the status code would be 429, so I guess it's not rate limiting?

I only found that there is a rate limit of 40 requests/second, but since CoreData is doing batch inserts, I think that I am not even close to that.

Core Data then tries again after the provided timeout, is able to insert another 400 elements and then receives 503 again.

If I try again ~60 minutes later, the process starts from the beginning.

What am I missing? Is there some undocumented "batch insert limit"?
NSPersistentCloudKitContainer - CloudKit Error 503 after inserting batch of elements
 
 
Q