dyedgreen / deno-sqlite

Deno SQLite module
https://deno.land/x/sqlite
MIT License
409 stars 36 forks source link

example of a busy handler? #200

Closed ralyodio closed 2 years ago

ralyodio commented 2 years ago

I have multiple processes writing to sqlite db simultaneously.

I tried setting PRAGMA busy_timeout = 30000 but that didn't fix my problem.

I have one long running process that queries db sequentially in a loop and if I run that, the whole app freezes and users can no long read from db.

I read something about creating an sqlite_busy_handler. Does anyone know how to solve this issue?

dyedgreen commented 2 years ago

Id suggest moving the database reads for your use facing app into a worker; this way your app can keep handling requests and you can simply queue up multiple reads to your worker.

This would work if your long running process finishes within an acceptable time for your app to be responsive again; otherwise there is not much you can do (other than maybe chunking your very long running expensive query into multiple smaller queries)

ralyodio commented 2 years ago

Got an example of this?

also why doesn't the pragma "busy_timeout" work?