Skip to content

Conversation

@rkistner
Copy link
Contributor

WASQLiteDBAdapter did not correctly lock read statements (get, getAll and getOptional). This meant these statements could be run in the middle of another transaction and return inconsistent results.

This also changes the global lock in open-db.ts to a local Mutex, since it is only relevant for that specific connection. This may give a minor performance improvement - navigator.locks can be slow when tabs/workers are busy.

@changeset-bot
Copy link

changeset-bot bot commented Jul 16, 2024

🦋 Changeset detected

Latest commit: a1b52be

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 11 packages
Name Type
@powersync/web Patch
angular-supabase-todolist Patch
example-capacitor Patch
example-electron Patch
example-nextjs Patch
example-vite Patch
react-multi-client Patch
react-supabase-todolist Patch
vue-supabase-todolist Patch
yjs-react-supabase-text-collab Patch
diagnostics-app Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@rkistner rkistner requested a review from stevensJourney July 16, 2024 10:10
expect(rows.length).toEqual(1);
expect(rows[0].name).toEqual('John');
expect(getAllSpy).toHaveBeenCalledTimes(1);
expect(getAllSpy).toHaveBeenCalledWith('SELECT * From users', []);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The watch from updateHasSynced (SELECT 1 FROM ps_buckets WHERE last_applied_op > 0 LIMIT 1) interfered with the toHaveBeenCalledTimes(1) test. The test worked previously, but the lock fix changed the timing of the call, which caused this test to break.

This now just tests that it has been called correctly once, and ignores any other calls.

@rkistner rkistner merged commit 9f35b78 into main Jul 16, 2024
@rkistner rkistner deleted the fix-web-locks branch July 16, 2024 11:40
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.

3 participants