Giter VIP home page Giter VIP logo

Comments (7)

thanhnguyen2187 avatar thanhnguyen2187 commented on May 28, 2024

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.

rhashimoto avatar rhashimoto commented on May 28, 2024

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.

rhashimoto avatar rhashimoto commented on May 28, 2024

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.

thanhnguyen2187 avatar thanhnguyen2187 commented on May 28, 2024

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.

rhashimoto avatar rhashimoto commented on May 28, 2024

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.

thanhnguyen2187 avatar thanhnguyen2187 commented on May 28, 2024

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.

abhay-agarwal avatar abhay-agarwal commented on May 28, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.