Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Local changes reverted when a replication delay is present #54

Open
rkistner opened this issue Jan 6, 2025 · 0 comments
Open

Local changes reverted when a replication delay is present #54

rkistner opened this issue Jan 6, 2025 · 0 comments

Comments

@rkistner
Copy link
Contributor

rkistner commented Jan 6, 2025

To reproduce:

  1. Stop the replication service, still running the API service.
  2. Make changes on the client and upload.
  3. Reconnect the client (restarting the app works for this).

This causes the local changes to be reverted. If you then restart the replication service and complete a sync, the changes appear again.

This is exactly the issue that write checkpoints is designed to prevent. The issue was reduced in #27, which changed the pseudo "$local" bucket to use pending_delete = 0 instead of 1. Client SDKs typically have this query to get current buckets: SELECT name as bucket, cast(last_op as TEXT) as op_id FROM ps_buckets WHERE pending_delete = 0. This change caused that query to include the "$local" bucket, which then causes it to remove removed when connecting, and reverting the local changes.

The issue is only triggered when the connects to the sync service, but there is a replication delay. It is therefore rare to see in practice without simulating a replication delay.

While the issue was introduced in this repo, the simplest fix is in the individual SDKs, by filtering out the $local bucket in the query mentioned above. A future version of powersync-sqlite-core will better abstract away the internals, which will avoid issues like this.

See test cases added in the Dart SDK here: powersync-ja/powersync.dart@5aa9919

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

No branches or pull requests

1 participant