Cannot open a READ_WRITE connection after a READ_ONLY connection even if it is closed
I might be doing something wrong here, but I'm wanting to use both READ_ONLY connections and READ_WRITE connections and even though it works most of the time there are cases where a READ_ONLY connection is ran first and once that happens any subsequent READ_WRITE connections fail to be created.
This is using Promises and async/await so I'm specifically waiting for connections to close before opening new connections as I know you can only have one READ_WRITE connection at a time.
Here is a Gist for example: https://gist.github.com/Rosslington/9aecbb3eb51386cd684cc6e538bfcfb9
I do not reproduce, using MacOS on either v0.9.2 or v0.10.0. Can you share more details of your setup?
Executing your reproduction like node reproduction.js I see behaviour as expected (so database opened with the various permissions as instructed).
Ah that's annoying. If it helps, this is running on Windows 11 v23H2 - Nodejs v21.2.0 - Duckdb v0.9.2
I'm running into the same issue. @ Windows 11 23H2 - Node.js v20.11.0 - DuckDB v1.0.0
My use case:
const tmpFilepath = './tmp/duckdb.db';
// Open a new db file with RW permissions so it would create the file
const db = new Database(tmpFilepath);
// Perform a query operation
await new Promise((resolve, reject) => {
db.run(`SELECT current_catalog()`, (error) => {
if (error) {
console.log(error);
reject(error);
}
resolve();
});
});
// Request releasing Database resources
await await new Promise((resolve, reject) => {
db.close((error) => {
if (error) {
console.log(error);
reject(error);
}
resolve();
});
)};
// Try to delete the file
await await new Promise((resolve, reject) => {
fs.rm(tmpFilepath, { recursive: true, force: true }, (error) => {
if (error) { // << "Error: EBUSY: resource busy or locked, unlink '<REMOVED>\tmp\duckdb.db'"
console.log(error);
reject(error);
}
resolve();
});
)};
Note: When I remove the SELECT current_catalog() query call the file is not locked and can be deleted.
i face the same problem like @vellotis .after close the db.the db file is still locked and can't remove!