Skip to content

Conversation

@stevensJourney
Copy link
Collaborator

@stevensJourney stevensJourney commented Nov 11, 2025

Overview

should close #763

The current Drizzle driver uses the AbstractPowerSyncDatabase writeLock method for most query operations. Read locks are only used if an explicit read only transaction is started.

Using a write lock for Select queries hampers concurrency in applications using environments which support multiple read connections - such as React Native and Node.js. Thanks @rkistner for adding this!

This PR updates the query execution logic to use queryMetaData from drizzle-team/drizzle-orm#4447 in order to detect SELECT queries. This approach has some limitations:

  • queryMetaData is not available for db.query[collectionName] queries. We use a slightly nasty override for db.query[collectionName] queries. The current version only has findMany and firstFirst options - which should be read queries

@changeset-bot
Copy link

changeset-bot bot commented Nov 11, 2025

🦋 Changeset detected

Latest commit: 7e4810d

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

This PR includes changesets to release 2 packages
Name Type
@powersync/drizzle-driver Minor
@powersync/node Minor

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

@stevensJourney stevensJourney marked this pull request as ready for review November 11, 2025 15:12
@stevensJourney
Copy link
Collaborator Author

The Test Packages action is still super flaky. I've seen the Node.JS sync tests fail almost 15 times :(. Skipping this for now in order to get this out.

@stevensJourney stevensJourney merged commit b7a150a into main Nov 12, 2025
8 of 24 checks passed
@stevensJourney stevensJourney deleted the drizzle-fix branch November 12, 2025 09:38
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.

Drizzle queries appear to use writeLock for SELECT statements - need help understanding if this is expected

4 participants