Comments (7)
I only mentioned code snippets that I feel important to wa-sqlite
. You are free to check out the full code here: thanhnguyen2187/crypta#28.
from wa-sqlite.
I agree that you're likely overlapping calls into wa-sqlite. That's on you to debug, I'm afraid. You might try setting a breakpoint on each API call you make to check the state of your application.
from wa-sqlite.
You could also try using the debug build. You would need to follow the build instructions from the README.md and make debug
, which writes the WASM artifacts to debug/ (instead of dist/). That might assert sooner and/or give you more actionable error messages.
from wa-sqlite.
Thanks a lot for the suggestion! I thought of another way to mitigate the issue and was going to work on it soon, but I'll also try the debugging WASM and let you know if there is anything relevant.
Another question: theoretically, wa-sqlite
(and IDBBatchAtomicVFS
) should be able handle concurrent reads, and mixed reading writing, right? I rechecked my code and there were two cases:
- One read, one write
- Two reads
from wa-sqlite.
theoretically, wa-sqlite (and IDBatchAtomicVFS) should be able handle concurrent reads, and mixed reading writing, right?
If you mean on the same instantiated WASM module, no. You cannot have multiple calls to SQLite in flight simultaneously.
If you mean concurrent transactions on the same database from different instantiated WASM modules (typically also from different JavaScript contexts), whether you can overlap transactions depends on locking support in the VFS you use. See this FAQ item for details.
from wa-sqlite.
If you mean on the same instantiated WASM module, no. You cannot have multiple calls to SQLite in flight simultaneously.
I see. Everything makes sense now. I'll elaborate the case for posterity.
There is this piece in my code:
export async function createSQLiteAPI(): Promise<SQLiteAPI> {
// @ts-ignore
const module = await SQLiteESMFactory()
const sqlite3 = SQLite.Factory(module)
const vfs = new IDBBatchAtomicVFS()
// const vfs = new OriginPrivateFileSystemVFS()
sqlite3.vfs_register(vfs, true)
return sqlite3
}
Where the returned result is used in another object. That object is utilized in two different places simultaneously (as per the first comment). In the end, it raises some seemingly unrelated stack traces.
from wa-sqlite.
What if you set up a pool of connections within a shared worker, and then accessed each of those connections using different locks? Or a hierarchical locking strategy?
from wa-sqlite.
Related Issues (20)
- Support concurrent access to multiple databases HOT 3
- RuntimeError: memory access out of bounds - IDBBatchAtomicVFS HOT 5
- Racy IDBBatchAtomicVFS behavior when calling methods directly HOT 6
- PRAGMA synchronous=0; causes `database disk image is malformed` for `IDBBatchAtomic` VFS HOT 4
- Replace sqlite with libsql
- Corruption in vlcn fork with FTS5 HOT 8
- IDBBatchAtomicVFS error: `TypeError: Cannot read properties of null (reading 'fileSize')` HOT 4
- Trigger on multiple tabs HOT 3
- Slow Query Execution for Tables with Diverse Data HOT 1
- Error: database disk image is malformed HOT 10
- Error: no such module: rtree HOT 2
- Feature request: add last_insert_rowid method
- sqlite3.exec throws "RuntimeError: memory access out of bounds" HOT 11
- Yarn install `Packing the package failed exit code 1` HOT 2
- mjs and masm files ( /dist) are missing HOT 4
- Full text support HOT 2
- Which VFS is the best?
- Call stack size exceeded of wasm asyncify HOT 7
- Example VFS locking can have name collisions across filesystems HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from wa-sqlite.