Skip to content

Child records deleted locally when their parent's save failed with quotaExceeded #547

Description

@jalalawqati

Description

When a user's iCloud storage is full, saving parent records in CloudKit fails with quotaExceeded. SyncEngine ignores this, and that record is never sent again. The record is kept locally on device however.

Later, when a child that references that parent record is sent later, CloudKit rejects it this time with referenceViolation, rather than quotaExceeded. handleSentRecordZoneChanges treats all referenceViolation errors as the parent being deleted from another device, and with the child's ON DELETE CASCADE, that child is deleted from the local database.

Checklist

  • I wrote this in my own words, and aimed to be as succinct as possible, even if I used AI to help research its content.
  • I have determined whether this bug is also reproducible in a vanilla SwiftUI project.
  • I have determined whether this bug is also reproducible in a vanilla GRDB project.
  • If possible, I've reproduced the issue using the main branch of this package.
  • This issue hasn't been addressed in an existing GitHub issue or discussion.

Expected behavior

When iCloud storage is full, records are still saved locally, and uploaded again once storage is available

Actual behavior

Children of a parent that was never uploaded to CloudKit are deleted because of referenceViolation when they are sent later to CloudKit. We observed this behavior in our app and we were able to consistently reproduce it with an iCloud account that had no free storage left. Turning off iCloud made child record persist locally

Reproducing project

https://github.com/jalalawqati/ReferenceViolationReproduce

SQLiteData version information

1.12.0

Sharing version information

2.10.1

GRDB version information

7.11.1

Destination operating system

iOS 26.6

Xcode version information

Xcode 26.6

Swift Compiler version information

swift-driver version: 1.148.6 Apple Swift version 6.3.3 (swiftlang-6.3.3.1.1 clang-2100.1.1.101)
Target: arm64-apple-macosx26.0

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions