-
-
Notifications
You must be signed in to change notification settings - Fork 402
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
How does it handle SQLITE_BUSY error? #155
Comments
If busy then you should maybe open the database with other app, and you forgot to save it. Or maybe because sqlite not yet finish querying |
When the database is busy, If you want to permit longer busy times, you could wrap your query in a try-catch-retry loop. However, it's more likely that you have some kind unintentional locking happening in your application (as @mandaputtra pointed out). |
Here's an example of a try-catch-retry loop. const db = require('better-sqlite3')('my-database.db');
const stmt = db.prepare(SQL);
while (true) {
try {
stmt.run();
break;
} catch (err) {
if (err.code !== 'SQLITE_BUSY') throw err;
}
} |
As of version 5.0.0, there's now an option to specify a custom timeout, instead of the default 5 seconds. Read about it here. |
For me I get the "This database connection is busy executing a query" error way before 5 seconds. |
same here, the timeout does not seem to be respected edit: I'm using |
How does it handle SQLITE_BUSY error? Can we handle it somehow properly to make first process to wait until another writes?
In node-sqlite3 there is an opened issue with handling sqlite busy error.
The text was updated successfully, but these errors were encountered: