trevyn / turbosql

An easy local data persistence layer for Rust, backed by SQLite.
211 stars 8 forks source link

Threading & transactions & async #4

Closed trevyn closed 3 years ago

trevyn commented 3 years ago

I’m leaning toward the best approach being thread_local! database connections, with SQLite handling concurrency at its level. This gives us some advantages:

Outstanding questions:

Next steps:

trevyn commented 3 years ago

related: https://github.com/rusqlite/rusqlite/issues/697

trevyn commented 3 years ago

https://youtu.be/4QZ0-vIIFug?t=2568

Explains that the best thing to do for async filesystem access (SQLite is filesystem access, basically) is to use a thread pool and just glue it into a Future.

trevyn commented 3 years ago

Ok, thinking about transactions and threading constraints:

trevyn commented 3 years ago

Do automatic retry on SQLITE_BUSY always, with some exponential backoff. (Unless there's some way to be notified by SQLite when a command should be retried.)

trevyn commented 3 years ago

Closed circa f30413b. For more details, see https://github.com/trevyn/turbosql#transactions-and-async