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

Core bug with busy timeout (not working) #1275

Closed
titanism opened this issue Oct 10, 2024 · 6 comments
Closed

Core bug with busy timeout (not working) #1275

titanism opened this issue Oct 10, 2024 · 6 comments

Comments

@titanism
Copy link

As per #155 and #1155 there still seems to be an issue with busy timeout not being respected.

The timeout option in new Database is not respected. For example, we set it to 10 seconds, and it sometimes immediately throws an error when the database is busy.

@JoshuaWise
Copy link
Member

Hi, could you provide a reproduce-able example?

@titanism
Copy link
Author

@JoshuaWise it's very hard to reproduce, but I'm having the same issue as commented here by another completely different user at #155 (comment)

The issue happens way before 5 seconds.

@neoxpert
Copy link
Contributor

Just out of curiosity, as there is nothing happening on the way down from setting the timeout on a new Database instance in JavaScript into the actual C function of sqlite: You are defining the timeout in milliseconds and you are not creating new instances of the database from several threads with different timeouts?

@titanism
Copy link
Author

Correct, one single database instance, and setting it in milliseconds.

@Prinzhorn
Copy link
Contributor

Prinzhorn commented Oct 11, 2024

and it sometimes immediately throws an error when the database is busy.

That does not mean the timeout does not work. SQLite does not guarantee that the timeout is respected. In case of a deadlock it will immediately throw SQLITE_BUSY.

The presence of a busy handler does not guarantee that it will be invoked when there is lock contention. If SQLite determines that invoking the busy handler could result in a deadlock, it will go ahead and return SQLITE_BUSY to the application instead of invoking the busy handler.

https://www.sqlite.org/c3ref/busy_handler.html

it's very hard to reproduce

Sounds a lot like a race condition that causes a deadlock.

Edit: in the linked issue you're saying

I'm using ava and it's using multiple processes/threads so that's probably culprit

But now you're saying

one single database instance

when asked if you're using

new instances of the database from several threads

Does that mean this issue is not related to your other comment? You have a single process, with a single thread and a single Database instance? In which case there could never be a timeout, because there is nothing to wait for.

@JoshuaWise
Copy link
Member

better-sqlite3 doesn't do anything with the "busy timeout" except pass it directly to the underlying SQLite3 library. So this can't be an issue with better-sqlite3. I recommend posting on the SQLite forum: https://sqlite.org/forum/forum

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

4 participants