denoland / deno

A modern runtime for JavaScript and TypeScript.
https://deno.com
MIT License
94.69k stars 5.26k forks source link

KV: Panic because sqlite DB is locked #20116

Closed marvinhagemeister closed 1 year ago

marvinhagemeister commented 1 year ago

I'm not able to reliable reproduce this reliably which makes me assume that this is some sort of race condition.

Steps to reproduce

Again, seems to be a race condition so I cannot reliably reproduce this 100% of the time.

  1. Clone https://github.com/fro-profesional/deno-queues/tree/main
  2. cd into fresh-project
  3. Run deno run -A --unstable dev.ts
  4. Go to the page in the browser
  5. CTRL+C to quit the server and run deno run -A --unstable dev.ts again to restart it
  6. Refresh the page in the browser to trigger another enqueue operation
============================================================
Deno has panicked. This is a bug in Deno. Please report this
at https://github.com/denoland/deno/issues/new.
If you can reliably reproduce this panic, include the
reproduction steps and re-run with the RUST_BACKTRACE=1 env
var set and include the backtrace in your report.

Platform: macos aarch64
Version: 1.36.0
Args: ["deno", "run", "-A", "--unstable", "dev.ts"]

thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: database is locked

Caused by:
    Error code 5: The database file is locked', ext/kv/sqlite.rs:331:10
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
Leokuma commented 1 year ago

I also have this error ocasionally on Ubuntu 22 in a project unrelated to Fresh. On Windows I think I never had it. Not sure if the OS matters though, because they were different machines.

lucacasonato commented 1 year ago

It's related to do two Deno processes opening the same KV database. cc @losfair