-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Add support for SQLite (was: Are there plans to support sqlite?) #28
Comments
Definitely. When we say the "Rust SQL Toolkit" our vision is to support all of the SQL databases at some point in the future. I would say SQLite is next on our list to add. |
This should stay open until SQLite support is merged. |
So our idea for making SQLite async is to operate it in WAL (write-ahead log) mode and run the blocking |
I think that running SQLite on another thread would probably be a better idea than futzing with the internals of its storage layer to get it to run asynchronously on the main thread; the overhead of one OS thread and the necessary communication should be very small compared to the network communication involved with the other backends, and messing with |
@emilazy It's more an experiment. If it doesn't pan out, we can totally do that. Keep in mind that this is exactly what SQLite recommends you to do though.
|
That same document also says:
I'm not sure if that also extends to using WAL mode in this way – if it does, then I think at the very least there should be a warning about potentially compromised data integrity, since it might only observably fail to pan out after people lose data ^^; |
I think it's pretty clear that the rest of the document beyond the heading is defunct.
To assuage any concerns, the first iteration of support will most likely "just" use spawn_blocking or equivalent around potentially blocking calls. Next, we'll attempt to mimic Keep in mind, this may not even be worth it. I don't have any hard numbers yet to say "yes, doing this is a large enough performance increase". |
If I understand correctly, your main concern is with syncing. According to the WAL documentation:
Then, why not operate in WAL mode and:
This way, no fsync appens outside of sqlx control. And it looks like there is good support for this kind of modification. From the same page:
To implement the run checkpoint from the application, this section recommends to use I hope my explanations are clear. |
Nope, this is treat sqlite as nosql. Data integrity is paramount in rdbms. As a user, I must NOT need to find that the sqlite driver do any kind of hack. |
If I understand the documentation correctly, the only thing that threatens data integrity would be setting |
For our initial implementation we were going to checkpoint after every query execution, so data can only be lost from the current operation before control is returned to the application, which is already a normal concern with SQLite. Honestly, if you want perfect durability you should not be using SQLite anyway. |
Why don't you let the user to decide when to checkout and vacuum, which mode he/she wants to use, etc? |
I fully agree, but that's something that can be discussed after the initial implementation is done. |
Support for SQLite is here: After experimenting with various methods, I've decided to execute all blocking operations on a worker thread. Most of the SQLite API can be ran on the "current" thread. In effect, it's just the Initial testing seems to hold up fine even with high concurrency. I'd love assistance with additional testing. It's definitely possible I'm missing something. @abonander I'm going to need your help for making sure the macro support for SQLite is done correctly. I added what I think should make it work. We probably should extend |
* Add Docker build CI to pull requests * Add SQLite document persistence through SQLx * Update README to describe configuration variables * Minor changes to README wording * Update image size estimate listed in README * Update frontend dependencies * Add direct database tests and restructure code * Clarify use of `SQLITE_URI` in Docker contexts
No description provided.
The text was updated successfully, but these errors were encountered: