Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

KV: Panic because sqlite DB is locked #20116

Closed
marvinhagemeister opened this issue Aug 10, 2023 · 2 comments · Fixed by #20189
Closed

KV: Panic because sqlite DB is locked #20116

marvinhagemeister opened this issue Aug 10, 2023 · 2 comments · Fixed by #20189
Assignees
Labels
bug Something isn't working correctly ext/kv Related to "Deno.openKv()" API

Comments

@marvinhagemeister
Copy link
Contributor

marvinhagemeister commented Aug 10, 2023

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
@marvinhagemeister marvinhagemeister added bug Something isn't working correctly ext/kv Related to "Deno.openKv()" API labels Aug 10, 2023
@Leokuma
Copy link

Leokuma commented Aug 10, 2023

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
Copy link
Member

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

losfair added a commit that referenced this issue Aug 17, 2023
Properly handle the `SQLITE_BUSY` error code by retrying the
transaction.

Also wraps database initialization logic in a transaction to protect
against incomplete/concurrent initializations.

Fixes #20116.
littledivy pushed a commit to littledivy/deno that referenced this issue Aug 21, 2023
Properly handle the `SQLITE_BUSY` error code by retrying the
transaction.

Also wraps database initialization logic in a transaction to protect
against incomplete/concurrent initializations.

Fixes denoland#20116.
littledivy pushed a commit that referenced this issue Aug 21, 2023
Properly handle the `SQLITE_BUSY` error code by retrying the
transaction.

Also wraps database initialization logic in a transaction to protect
against incomplete/concurrent initializations.

Fixes #20116.
losfair added a commit to losfair/deno that referenced this issue Aug 24, 2023
Properly handle the `SQLITE_BUSY` error code by retrying the
transaction.

Also wraps database initialization logic in a transaction to protect
against incomplete/concurrent initializations.

Fixes denoland#20116.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working correctly ext/kv Related to "Deno.openKv()" API
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants