Skip to content

Keep children of never-uploaded parents and retry quotaExceeded saves - #548

Open
jalalawqati wants to merge 1 commit into
pointfreeco:mainfrom
jalalawqati:fix-reference-violation-data-loss
Open

jalalawqati wants to merge 1 commit into
pointfreeco:mainfrom
jalalawqati:fix-reference-violation-data-loss

Conversation

@jalalawqati

@jalalawqati jalalawqati commented Sep 15, 2026 •

Copy link
Copy Markdown

Description

Fixes #547

When a user's iCloud storage is full, a parent table save fails with quotaExceeded and is dropped. When one of the parent's child tables is sent later, it this time fails with referenceViolation (rather than quotaExceeded), and SyncEngine applies the parent's ON DELETE action, causing the child table to be deleted.

We couldn't find a clean fix to get around this in our app unfortunately. Happy to know your suggestions.

We tested the changes in this branch with our app on a device with full iCloud storage and the issue was no longer reproducible

sdvz added a commit to sdvz/sqlite-data that referenced this pull request Sep 29, 2026
…eeco#548)

Backported to 1.6.0 from pointfreeco#548, which fixes pointfreeco#547.

When a parent record's save is dropped (quotaExceeded, and any other error
handleSentRecordZoneChanges swallows with `continue`), a child sent later is
rejected with referenceViolation. The handler read that as "the parent was
deleted remotely" and applied the FK's ON DELETE CASCADE, destroying the
child row locally.

This skips the destructive branch when the parent has no lastKnownServerRecord
— i.e. it was never on the server, so nothing was deleted — and re-enqueues
parent and child instead. Also moves quotaExceeded into the retry branch.

Source hunks only; the PR's mock and test changes are omitted.

Remove this fork once pointfreeco#548 merges and ships upstream; upgrade straight to
that release rather than rebasing this patch.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

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

1 participant