Skip to content

Fix duplicate entries in ps_sync_state #63

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

Merged
merged 3 commits into from
Mar 6, 2025

Conversation

simolus3
Copy link
Contributor

@simolus3 simolus3 commented Mar 5, 2025

The priority column in ps_sync_state should have been a primary key to prevent duplicates (we're already using INSERT OR REPLACE when inserting).

This bumps the schema version and re-creates the table when migrating, only keeping the most recent item in each priority from the old ps_sync_state table.
I've also added tests asserting that:

  1. Inserting data into the old schema and then migrating only keeps the relevant rows.
  2. Calling sync_local multiple times with a VFS mocking the current time inserts or updates rows in ps_sync_state as expected, and doesn't cause duplicate entries.

@simolus3 simolus3 requested a review from rkistner March 5, 2025 15:31
@simolus3 simolus3 merged commit 0386fb5 into main Mar 6, 2025
12 checks passed
@simolus3 simolus3 deleted the fix/duplicate-last-synced-at branch March 6, 2025 13:48
@simolus3 simolus3 mentioned this pull request Mar 6, 2025
9 tasks
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.

2 participants