You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Rust’s 1.72 clippy now issues a warning about all 3 of our DbInner Arc usages:
--> tokenserver-db/src/models.rs:80:20
|
80 | inner: Arc::new(inner),
| ^^^^^^^^^^^^^^^
|
= note: the trait `Sync` is not implemented for `DbInner`
= note: required for `Arc<DbInner>` to implement `Send` and `Sync`
= help: consider using an `Rc` instead or wrapping the inner type with a `Mutex`
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#arc_with_non_send_sync
= note: `-D clippy::arc-with-non-send-sync` implied by `-D warnings`This is a good warning, however it’s not 100% valid for our Mysql based implementations (sync and tokenserver) because we force `Send` on their overall `Db` structs (via unsafe so we can send their calls to a thread). We'll mark these to skip the warnings going forward but we could consider alternative ways of doing this that wouldn’t trigger clippy.
Basically we want to force Send for the sake of sending these calls to a thread. For Arc to be Send it requires the Inner fields to be Sync. So we essentially want to unsafe force Sync for the ability to Send. This is safe for us because we only send these values to our threadpool which blocks the async task until it’s finished running.
The warning suggests we don’t actually need the Arc for the spanner impl because it doesn’t implement Send/Sync.
So 2 parts:
Replace Spanner’s Arc w/ Rc
Consider alternatives to how we unsafe the Send for our blocking threadpool implementations
Rust’s 1.72 clippy now issues a warning about all 3 of our
DbInner
Arc usages:Basically we want to force
Send
for the sake of sending these calls to a thread. For Arc to beSend
it requires the Inner fields to beSync
. So we essentially want to unsafe forceSync
for the ability toSend
. This is safe for us because we only send these values to our threadpool which blocks the async task until it’s finished running.The warning suggests we don’t actually need the
Arc
for the spanner impl because it doesn’t implementSend/Sync
.So 2 parts:
Arc
w/Rc
Send
for our blocking threadpool implementations┆Issue is synchronized with this Jira Task
The text was updated successfully, but these errors were encountered: