Skip to content

Commit e7b1d89

Browse files
committed
Write/Read lock fix.
1 parent e90b12c commit e7b1d89

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

.changeset/rotten-rats-raise.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@powersync/react-native': patch
3+
---
4+
5+
Fixed an issue where the read and write locks were executing mutually exclusively. A read conccurent with a write or another read should correctly proceed instead of being blocked until the other lock has released.

packages/react-native/src/db/PowerSyncDatabase.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,4 +58,14 @@ export class PowerSyncDatabase extends AbstractPowerSyncDatabase {
5858
identifier: this.database.name
5959
});
6060
}
61+
62+
async readLock<T>(callback: (db: DBAdapter) => Promise<T>): Promise<T> {
63+
await this.waitForReady();
64+
return this.database.readLock(callback);
65+
}
66+
67+
async writeLock<T>(callback: (db: DBAdapter) => Promise<T>): Promise<T> {
68+
await this.waitForReady();
69+
return this.database.writeLock(callback);
70+
}
6171
}

0 commit comments

Comments
 (0)