ncruces / go-sqlite3

Go bindings to SQLite using wazero
https://pkg.go.dev/github.com/ncruces/go-sqlite3
MIT License
402 stars 12 forks source link

How to solve GoError: failed to upgrade database: sqlite3: disk I/O error #109

Closed frmdeveloper closed 2 months ago

frmdeveloper commented 2 months ago

When I run with wasm nodejs, I get an error like this Screenshot_20240628_195725_Termux

import (
  ...
      "go.mau.fi/whatsmeow/store/sqlstore"
    _ "github.com/ncruces/go-sqlite3/driver"
    _ "github.com/ncruces/go-sqlite3/embed"
)

...
container, err := sqlstore.New("sqlite3", "file:tes.db", dbLog)
ncruces commented 2 months ago

I have… no idea?

What's "wasm nodejs"? What's sqlstore? Never heard of it. _foreign_keys=on does nothing for this driver.

How can I reproduce the bug? I copy those 6 lines to a file and run it?

Your chances of getting help will improve incredibly if you post a good bug report.

frmdeveloper commented 2 months ago

What's "wasm nodejs"?

If run in the main golang program, it is safe. But if run using WebAssembly in NodeJS, an error occurs disk I/O error

$ env GOOS=js GOARCH=wasm go build -o test.wasm
$ node $(go env GOROOT)/misc/wasm/wasm_exec_node.js test.wasm

What's sqlstore? Never heard of it. _foreign_keys=on does nothing for this driver.

just forget about that

ncruces commented 2 months ago

OK you're nesting Wasm inside Wasm. That's not really the intended use for this.

Still, the issue is probably that file locking is not supported with either wasm/js or wasm/wasip1.

Read this carefully, understand the implications, and use nolock=1.