You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Fetch path: a CKAsset that fails to load drops the record for good (NOT NULL BLOB, change token moves on)
#595
What happens. In SyncEngine.upsert(_:record:columnNames:) (fetch path) a CKAsset column is loaded with try? asset.fileURL.map { try dataManager.wrappedValue.load($0) }. When the load fails (file missing, partial
download, disk full), NULL is bound. For a NOT NULL BLOB column the upsert then throws SQLITE_CONSTRAINT_NOTNULL inside withErrorReporting(.sqliteDataCloudKitFailure). The error is reported, but:
the row keeps its old values (good: no NULL written),
lastKnownServerRecord does not move,
the zone's change token moves on, so the record is not delivered again by later fetches.
The device stays on the old state until the next change of that record arrives. A local write of that row
(an own edit, or a no-op UPDATE as an attempted re-fetch) is sent on the stale last known record, runs into serverRecordChanged, and on MockCloudContainer the device keeps its stale value while its last known server
record moves on (the save is queued again and accepted on the next send): the newer server value from the other
device is overwritten. Measured for an own write that sets the row back to the stale value; a no-op write is the
same kind of trigger-driven change and is expected to behave alike. So there is no safe app-side way to re-fetch. updateQuery reports "Asset data not found on disk"; the fetch path does not.
Repro (mock). Upload a row with a NOT NULL BLOB column, fetch it again under a different withDependencies { $0.context = ... } so the in-memory DataManager lacks the asset: one report
(NOT NULL constraint failed), row unchanged, a second fetchChanges() delivers nothing.
Ask. One of:
Do not advance past a record whose asset could not be loaded (fail the batch, or keep it in UnsyncedRecordID like the foreign-key case and retry it), or
a public API to re-fetch single records (e.g. fetchRecords(_ ids:) that runs the normal upsert path), or
at least the same "Asset data not found on disk" report on the fetch path, with the record ID.
Our workaround. An IssueReporter classifies the NOT NULL report and the app shows a note in its sync
section until the last known server record of that table has moved on.
Related:#584 covers the same try? … ?? "NULL" load on the save-conflict path (handleSentRecordZoneChanges). This report is about the fetch path, where the change token moves on and the record is not delivered again.
Prepared with AI assistance; the behavior was measured with MockCloudContainer in our app tests.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
Version: SQLiteData 1.13.0 (CKSyncEngine, iOS 26).
What happens. In
SyncEngine.upsert(_:record:columnNames:)(fetch path) aCKAssetcolumn is loaded withtry? asset.fileURL.map { try dataManager.wrappedValue.load($0) }. When the load fails (file missing, partialdownload, disk full),
NULLis bound. For aNOT NULLBLOB column the upsert then throwsSQLITE_CONSTRAINT_NOTNULLinsidewithErrorReporting(.sqliteDataCloudKitFailure). The error is reported, but:lastKnownServerRecorddoes not move,The device stays on the old state until the next change of that record arrives. A local write of that row
(an own edit, or a no-op
UPDATEas an attempted re-fetch) is sent on the stale last known record, runs intoserverRecordChanged, and onMockCloudContainerthe device keeps its stale value while its last known serverrecord moves on (the save is queued again and accepted on the next send): the newer server value from the other
device is overwritten. Measured for an own write that sets the row back to the stale value; a no-op write is the
same kind of trigger-driven change and is expected to behave alike. So there is no safe app-side way to re-fetch.
updateQueryreports "Asset data not found on disk"; the fetch path does not.Repro (mock). Upload a row with a
NOT NULLBLOB column, fetch it again under a differentwithDependencies { $0.context = ... }so the in-memoryDataManagerlacks the asset: one report(
NOT NULL constraint failed), row unchanged, a secondfetchChanges()delivers nothing.Ask. One of:
UnsyncedRecordIDlike the foreign-key case and retry it), orfetchRecords(_ ids:)that runs the normal upsert path), orOur workaround. An
IssueReporterclassifies the NOT NULL report and the app shows a note in its syncsection until the last known server record of that table has moved on.
Related: #584 covers the same
try? … ?? "NULL"load on the save-conflict path (handleSentRecordZoneChanges). This report is about the fetch path, where the change token moves on and the record is not delivered again.Prepared with AI assistance; the behavior was measured with
MockCloudContainerin our app tests.All reactions