Skip to content

Conversation

simolus3
Copy link
Contributor

@simolus3 simolus3 commented Sep 9, 2025

Consider the following sequence of events:

  1. The client is offline and mutates the database.
  2. The client connects, and starts uploading changes.
  3. That triggers a new checkpoint that gets synced down. It can't be applied because $local.target_op is at 1<<62.
  4. The connector is done, the client SDK requests a write checkpoint.
  5. We get a write checkpoint response, it's 1.
  6. Because the upload has finished, we send an upload_completed notification to the Rust client. That tries applying the previous checkpoint, which fails because it doesn't have a write checkpoint. A "Could not apply pending checkpoint even after completed upload" warning message is logged.
  7. A new checkpoint with the write checkpoint is synced down and applied.

This is actually fairly common, and a completely harmless sequence of events that both the service and the client handle correctly. It's just the warning message that stands out here. So, this PR removes that message.

This also adds tests for:

  1. The checkpoint containing a requested write checkpoint being synced before the crud upload task in SDKs completes (completing it should apply the checkpoint, recently handled correctly).
  2. The crud upload completing and triggering a new checkpoint with the data and write checkpoint (we've always handled this one correctly).
  3. Receiving a data checkpoint first and a write checkpoint later (there shouldn't be the annoying warning message).
  4. A second local write after the first one has been uploaded (this should still trigger the warning message to notify developers about why the sync couldn't be completed).

Closes powersync-ja/powersync-kotlin#243.

@simolus3 simolus3 requested a review from rkistner September 9, 2025 15:55
@simolus3 simolus3 merged commit bb6f564 into main Sep 10, 2025
23 checks passed
@simolus3 simolus3 deleted the avoid-could-not-apply-message branch September 10, 2025 14:51
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.

Could not apply pending checkpoint even after completed upload
2 participants