You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In an attempt to test the behaviour of an SQL statement when run in parallel, I tried to execute the statement from multiple workers.
Here is a striped-down version of the code:
// main.tsimport{DB}from"https://deno.land/x/[email protected]/mod.ts";constfilename="test.sqlite";constdb=newDB(filename);db.execute("drop table if exists t; create table t (c text);");constworkers: Worker[]=[];constworkerPromises: Promise<void>[]=[];for(letindex=0;index<10;index++){constworker=newWorker(newURL("./worker.ts",import.meta.url).href,{name: "worker "+index,type: "module"},);constdeferred=Promise.withResolvers<void>();worker.onmessage=()=>deferred.resolve();worker.onmessageerror=()=>deferred.reject();workers.push(worker);workerPromises.push(deferred.promise);}workers.forEach((worker)=>worker.postMessage({ filename }));awaitPromise.all(workerPromises);db.queryEntries("select * from t").forEach((row)=>console.log(row));db.close();
// worker.ts/// <reference lib="webworker" />import{DB}from"https://deno.land/x/[email protected]/mod.ts";self.onmessage=(event)=>{const{ filename }=event.data;constdb=newDB(filename,{mode: "write"});db.query("insert into t (c) values (:c)",{c: "inserted by "+self.name});db.close();self.postMessage({done: true});self.close();};
When the VFS is asked to delete a journal file, it raises this error:
error: Uncaught (in worker "worker 1") NotFound: No such file or directory (os error 2): remove 'test.sqlite-journal'
Deno.removeSync(path);
^
at Object.removeSync (ext:deno_fs/30_fs.js:209:7)
at js_delete (https://deno.land/x/[email protected]/build/vfs.js:39:12)
at <anonymous> (wasm://wasm/0028679a:1:5597)
...
error: Uncaught (in promise) Error: Unhandled error in child worker.
at Worker.#pollControl (ext:runtime/11_workers.js:164:19)
at eventLoopTick (ext:core/01_core.js:182:7)
After reading #240 and #249 I'm uncertain if the code should get thus far. However, the SQLite demo VFS seems to silently ignore request to delete a non-existing file and returns SQLITE_OK (search for demoDelete).
The text was updated successfully, but these errors were encountered:
Yes, I think this looks like an issue with file locking (I think the denk api is still unstable as well) but essentially it’s currently not really possible to detect locks held by the same deno process.
I feel like failing loudly when there is an unexpected problem like this seems better than to silently ignore the error though? (Eg in this instance you noticed there is an issue with concurrent access from the same process, which might not have been obvious if the error was swallowed.)
In an attempt to test the behaviour of an SQL statement when run in parallel, I tried to execute the statement from multiple workers.
Here is a striped-down version of the code:
When the VFS is asked to delete a journal file, it raises this error:
After reading #240 and #249 I'm uncertain if the code should get thus far. However, the SQLite demo VFS seems to silently ignore request to delete a non-existing file and returns
SQLITE_OK
(search fordemoDelete
).The text was updated successfully, but these errors were encountered: