Skip to content

Commit b38bcdb

Browse files
authored
chore: Update opsqlite 11.2.13 (#463)
1 parent e52af89 commit b38bcdb

File tree

6 files changed

+90
-115
lines changed

6 files changed

+90
-115
lines changed

.changeset/hip-pianos-relax.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@powersync/op-sqlite': patch
3+
---
4+
5+
Update op-sqlite to v11.2.13.

.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/powersync-op-sqlite/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@
6565
"access": "public"
6666
},
6767
"peerDependencies": {
68-
"@op-engineering/op-sqlite": "^10.1.0",
68+
"@op-engineering/op-sqlite": "^11.2.13",
6969
"@powersync/common": "workspace:^1.22.1",
7070
"react": "*",
7171
"react-native": "*"
@@ -75,7 +75,7 @@
7575
"async-lock": "^1.4.0"
7676
},
7777
"devDependencies": {
78-
"@op-engineering/op-sqlite": "^10.1.0",
78+
"@op-engineering/op-sqlite": "^11.2.13",
7979
"@react-native/eslint-config": "^0.73.1",
8080
"@types/async-lock": "^1.4.0",
8181
"@types/react": "^18.2.44",

packages/powersync-op-sqlite/src/db/OPSqliteAdapter.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -78,9 +78,7 @@ export class OPSQLiteDBAdapter extends BaseObserver<DBAdapterListener> implement
7878

7979
this.readConnections = [];
8080
for (let i = 0; i < READ_CONNECTIONS; i++) {
81-
// Workaround to create read-only connections
82-
let dbName = './'.repeat(i + 1) + dbFilename;
83-
const conn = await this.openConnection(dbName);
81+
const conn = await this.openConnection(dbFilename);
8482
await conn.execute('PRAGMA query_only = true');
8583
this.readConnections.push({ busy: false, connection: conn });
8684
}

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)