Skip to content

Commit 05a3e57

Browse files
committed
Remove prelock support.
1 parent 81465a6 commit 05a3e57

7 files changed

Lines changed: 1 addition & 58 deletions

File tree

packages/driver/src/driver-api.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,6 @@ export interface SqliteDriverConnection {
3535
getLastChanges(): Promise<SqliteChanges>;
3636

3737
close(): Promise<void>;
38-
39-
lock?(mode: 'exclusive' | 'shared' | 'deferred'): Promise<void>;
40-
release?(): void;
4138
}
4239

4340
export type SqliteParameterBinding =

packages/driver/src/util/SingleConnectionPool.ts

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@ export class SingleConnectionPool implements SqliteDriverConnectionPool {
3737
async () => {
3838
// TODO: sync
3939
if (this.inUse === reserved) {
40-
reserved.connection.release?.();
4140
this.inUse = null;
4241
Promise.resolve().then(() => this.next());
4342
}
@@ -46,9 +45,6 @@ export class SingleConnectionPool implements SqliteDriverConnectionPool {
4645

4746
if (this.inUse == null) {
4847
this.inUse = reserved;
49-
await reserved.connection.lock?.(
50-
options?.readonly ? 'shared' : 'exclusive'
51-
);
5248
return reserved;
5349
} else {
5450
const promise = new Promise<ReservedConnection>((resolve, reject) => {
@@ -70,9 +66,6 @@ export class SingleConnectionPool implements SqliteDriverConnectionPool {
7066

7167
return promise.then(async (r) => {
7268
this.inUse = reserved;
73-
await reserved.connection.lock?.(
74-
options?.readonly ? 'shared' : 'exclusive'
75-
);
7669
return r;
7770
});
7871
}

packages/wa-sqlite-driver/src/OPFSCoopSyncVFS2.ts

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -92,20 +92,6 @@ export class OPFSCoopSyncVFS2 extends FacadeVFS {
9292
return (this as unknown as WithModule)._module;
9393
}
9494

95-
async prelock(fileName: string): Promise<Disposable> {
96-
const file = this.persistentFiles.get('/' + fileName);
97-
this.log?.('prelock', fileName, file);
98-
await this.#requestAccessHandle(file);
99-
this.log?.('prelocked', fileName);
100-
const self = this;
101-
return {
102-
[Symbol.dispose]() {
103-
this.log?.('prelock release', fileName);
104-
self.#releaseAccessHandle(file);
105-
}
106-
};
107-
}
108-
10995
async #initialize(nTemporaryFiles) {
11096
// Delete temporary directories no longer in use.
11197
const root = await navigator.storage.getDirectory();

packages/wa-sqlite-driver/src/wa-sqlite-driver.ts

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,6 @@ export class WaSqliteConnection implements SqliteDriverConnection {
257257
vfs: OPFSCoopSyncVFS2;
258258

259259
statements = new Set<StatementImpl>();
260-
lockDisposer: Disposable | null = null;
261260

262261
static async open(
263262
filename: string,
@@ -277,15 +276,6 @@ export class WaSqliteConnection implements SqliteDriverConnection {
277276
this.vfs = vfs;
278277
}
279278

280-
async lock() {
281-
this.lockDisposer = await this.vfs.prelock(this.path);
282-
}
283-
284-
release() {
285-
this.lockDisposer[Symbol.dispose]();
286-
this.lockDisposer = null;
287-
}
288-
289279
async close() {
290280
await m.runExclusive(async () => {
291281
console.log('closing...', this.path);

packages/wa-sqlite-driver/src/worker_threads/WorkerDriverAdapter.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -115,10 +115,6 @@ export class WorkerConnectionAdapter implements WorkerDriver {
115115
return this._parse(command);
116116
case SqliteCommandType.changes:
117117
return this.connnection.getLastChanges();
118-
case SqliteCommandType.lock:
119-
return this.connnection.lock?.(command.mode);
120-
case SqliteCommandType.release:
121-
return this.connnection.release?.();
122118
default:
123119
throw new Error(`Unknown command: ${command.type}`);
124120
}

packages/wa-sqlite-driver/src/worker_threads/async-commands.ts

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -91,15 +91,6 @@ export interface SqliteGetChanges {
9191
type: SqliteCommandType.changes;
9292
}
9393

94-
export interface SqliteLock {
95-
type: SqliteCommandType.lock;
96-
mode: 'exclusive' | 'shared' | 'deferred';
97-
}
98-
99-
export interface SqliteRelease {
100-
type: SqliteCommandType.release;
101-
}
102-
10394
export type SqliteCommand =
10495
| SqlitePrepare
10596
| SqliteBind
@@ -109,9 +100,7 @@ export type SqliteCommand =
109100
| SqliteFinalize
110101
| SqliteSync
111102
| SqliteParse
112-
| SqliteGetChanges
113-
| SqliteLock
114-
| SqliteRelease;
103+
| SqliteGetChanges;
115104

116105
export type InferCommandResult<T extends SqliteCommand> = T extends SqliteRun
117106
? SqliteChanges

packages/wa-sqlite-driver/src/worker_threads/worker-driver.ts

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -70,14 +70,6 @@ export class WorkerDriverConnection implements SqliteDriverConnection {
7070
return this.post('open', this.options);
7171
}
7272

73-
async lock(mode: 'exclusive' | 'shared' | 'deferred'): Promise<void> {
74-
await this._send({ type: SqliteCommandType.lock, mode: mode });
75-
}
76-
77-
release(): void {
78-
this._send({ type: SqliteCommandType.release });
79-
}
80-
8173
prepare(sql: string, options?: PrepareOptions): WorkerDriverStatement {
8274
const id = this.nextId++;
8375
this.buffer.push({

0 commit comments

Comments
 (0)