-
Notifications
You must be signed in to change notification settings - Fork 257
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
SQLite libsql tidying #1545
SQLite libsql tidying #1545
Conversation
Thanks so much for working on this! ❤️ I'm fine with making the path configuration match the behavior of the key-value store config. |
Regarding this:
After a bit more testing, it looks like this was an issue only with executing SQL during startup (via the If spawning a thread for the secondary runtime is the correct solution, should that be something we do in the libsql provider I like doing it in the libsql provider because then consumers don't have to worry about it on a case-by-case basis. But it does add an overhead on every outbound libsql call - probably insignificant in timing terms compared to the network hop (though I have not measured it under any kind of load), but possibly a scaling issue if a lot of guests do it at the same time and run up a large number of OS threads. A FANCY SCHMANCY solution would be to have the provider determine if it is within a tokio runtime: if so, it could spawn a thread for the secondary runtime, and if not it could create the secondary runtime there and then... |
The fancy schmancy trick didn't help. Calls from the Wasm guest still show as being in a Tokio runtime, so still go down the "spawn a thread" branch even though we have seen that it's unnecessary. |
a3eada8
to
d19fcb7
Compare
Added a fix for inproc storage location to print the database file not just the directory, and for the runtime config file to specify the exact file path. I provisionally changed the default filename from
I've tested the changes for both the default default, the default mapped in the runtime config, and a nondefault database. |
This now implements the I have to admit I am not delighted with the libsql implementation though. |
0c13f1b
to
36db293
Compare
This is ready for review (I am happy to squash commits a bit more but wanted to leave the last couple in place in case we dislike them that much). It would be great to land it sooner rather than later, because it is already quite big, and I'd like the next lot of SQLite fixes and improvements to go into this structure, rather than being applied to the current crate and causing big merge conflicts (which is it is so big to be honest - I had fixes so I put them in here rather than waiting until it was merged or rejected!). One thing that's lacking is tests. I think we can do at least in-proc ones in the same vein as the K/V integration tests. But again I'd kind of like to get this in then go back and battle the integration tests when they won't hold up the merge. @radu-matei @dicej it would be great if you could take a look - I know @rylev is the authority on this but I'm not sure when he'll be available. |
Gave this branch a try after the updates and things LGTM.
Everything seems to be working properly — the migrations file is handled properly across implementations, and @rylev's basic todo app (https://github.com/rylev/spin-todo) works great! |
Thanks @radu-matei - I will give it some more squash, then merge, and of course iterate with @rylev when he gets back. |
Signed-off-by: Ryan Levick <ryan.levick@fermyon.com>
Signed-off-by: itowlson <ivan.towlson@fermyon.com>
Signed-off-by: itowlson <ivan.towlson@fermyon.com>
Signed-off-by: itowlson <ivan.towlson@fermyon.com>
Signed-off-by: itowlson <ivan.towlson@fermyon.com>
Signed-off-by: itowlson <ivan.towlson@fermyon.com>
36db293
to
931a8c4
Compare
This builds on, and includes, @rylev's #1539. The new stuff included here is:
inproc
for the rusqlite/default implementation but that is totally up for grabsSend
, and this fix dug me out of a hole.spin up --sqlite
and the Rust SDK against a Turso back endImportant notes:
libsql://
prefix in theurl
. It should ONLY be the Turso host name.The file backed location message is misleading. The current behaviour is that if you use the default it createsI made a (proposed) decision on the path and it now prints it..spin/default.db
but it prints only the directory. I have not fixed the printing because I want us to agree on the path.It does not yet seem possible to set nondefault in-proc database locations in the runtime config file. It appears to treat a path as a directory, and then wantsPer Ryan's comment, I implemented K/V style behaviour.<spin-name>.db
inside that directory, but it errors if the file does not already exist. Again, I can fix this but I want to get agreement on the desired behaviour first. (My mental model for this was the K/V one where you specify a file, and it creates it if it doesn't already exist.)This needs squashing and could do with a bit more tidying (indents: let us never speak of them again), but I wanted to share it for people to kick the tyres and to get feedback on the desired behaviour for the runtime config behaviour.