I was lead to believe that SQLite could be safely and efficiently used by multiple threads within a single process. Was I wrong?
@mcc a sqlite connection pointer can be safely moved between threads, but it does not perform internal synchronization and so can not be used by more than one thread at the same time. you can open more connections and distribute connections among threads to get concurrency. in wal mode the concurrency can be parallel for reads, but at most only one writer will proceed at a time.
If you have a fediverse account, you can quote this note from your own instance. Search https://don.rag.pub/users/raggi/statuses/115272702604609932 on your instance and quote it. (Note that quoting is not supported in Mastodon.)
![error[E0277]: `NonNull<libsqlite3_sys::bindings::sqlite3>` cannot be shared between threads safely
--> server/src/main.rs:146:32
|
146 | rocket = rocket.manage(state::AppState {self_url, engine, connection});
| ------ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `NonNull<libsqlite3_sys::bindings::sqlite3>` cannot be shared between threads safely
| |
| required by a bound introduced by this call
|
= help: within `AppState`, the trait `Sync` is not implemented for `NonNull<libsqlite3_sys::bindings::sqlite3>`](https://files.mastodon.social/media_attachments/files/115/272/610/932/412/005/original/cbce63dd95318381.png)