evidence icon indicating copy to clipboard operation
evidence copied to clipboard

DuckDB Connector Locks DuckDB file

Open archiewood opened this issue 2 years ago • 8 comments

Steps To Reproduce

  1. Connect evidence to the needful things database in the example project
  2. (install and run the duckdb DB)
  3. run .open needful_things.duckdb

Environment

  • OS: MacOS 13.4.1
  • Database: duckdb

Expected Behavior

Can access duckdb from another program

Actual Behaviour

Error: unable to open database "needful_things.duckdb": IO Error: Could not set lock on file "needful_things.duckdb": Resource temporarily unavailable

archiewood avatar Jul 21 '23 20:07 archiewood

Is this happening while a query is running or just in general while the dev server is open?

csjh avatar Jul 21 '23 20:07 csjh

In general while the dev server is open.

I suspect we arent closing the connection properly after running queries or something like that

archiewood avatar Jul 21 '23 21:07 archiewood

Do you suspect this is an issue with the underlying library? or the way we are implementing it? https://github.com/motherduckdb/duckdb-async

archiewood avatar Jul 24 '23 17:07 archiewood

No, it's because we never actually close the connection, so I would assume it just lasts until the dev server is closed or the GC picks it up

csjh avatar Jul 24 '23 17:07 csjh

I might be wrong, but I think there isn't a close method implemented in duckdb-async?

archiewood avatar Jul 24 '23 17:07 archiewood

I am wrong: https://github.com/motherduckdb/duckdb-async/blob/868886e3beac197c97fe30673f894938e806c646/src/duckdb-async.ts#L322

archiewood avatar Jul 24 '23 17:07 archiewood

Yeah, we could just put await db.close() right after executing

csjh avatar Jul 24 '23 17:07 csjh

I think this has been fixed w/ #1483's closeConnection callback

csjh avatar Sep 16 '24 16:09 csjh