Repository navigation
Conversation
rkistner
left a comment
There was a problem hiding this comment.
There's another case here: If we receive a checkpoint_complete with both priority 0 and priority 1 buckets, and the apply is blocked by local changes - can we still apply the priority 0 changes?
Wouldn't we receive a |
|
Ok, confirmed that the service always sends a partial_checkpoint_complete between buckets of different priorities. We should probably formalize the spec for that, to ensure we don't change that in the future without considering this use case |
Changes from buckets with priority zero are supposed to be applied even if there's local data (in
ps_crud, or atarget_checkpoint_request_idthat has not yet been reached). Usually, this works with the PowerSync service sending priority 0 data followed by apartial_checkpoint_complete.When all buckets in a checkpoint have priority zero, there's no
partial_checkpoint_completemessage. The service sends all bucket data followed bycheckpoint_complete. We should still be able to run an implicit partial checkpoint at this point.Note
We can't simply ignore the
can_apply_sync_changescheck for full checkpoints consisting exclusively of priority zero buckets. The reason is that a full sync also considersps_updated_rows, so a concurrent checkpoint before these have been uploaded would lead to flicker even for insert-only tables. Running a partial checkpoint before a full checkpoint (which would then fail due to local data) is necessary.To fix this, we check if all buckets are of priority zero when a full checkpoint failed due to local data. If that's the case, we retry as a partial checkpoint. The sync client needs to react to this "downgrade", because we shouldn't set the global
lastSyncedAtfield here.AI use: Reviewed with Claude Code, which found some issues where a full checkpoint downgraded to a partial checkpoint would not be retried after a crud upload notification. Fixed that with Claude as well.