sfackler/r2d2

can't send PooledConnection to other thread

kanekv opened this issue · 1 comments

I'm trying to wrap PooledConnection in the Mutex and getting this:

`std::ptr::NonNull<pq_sys::pg_conn>` cannot be shared between threads safely
within `r2d2::PooledConnection<embedded_migrations::diesel::r2d2::ConnectionManager<embedded_migrations::diesel::PgConnection>>`, the trait `std::marker::Sync` is not implemented for `std::ptr::NonNull<pq_sys::pg_conn>`
required because it appears within the type `embedded_migrations::diesel::pg::connection::raw::RawConnection`
required because it appears within the type `embedded_migrations::diesel::PgConnection`
required because it appears within the type `r2d2::Conn<embedded_migrations::diesel::PgConnection>`
required because it appears within the type `std::option::Option<r2d2::Conn<embedded_migrations::diesel::PgConnection>>`
required because it appears within the type `r2d2::PooledConnection<embedded_migrations::diesel::r2d2::ConnectionManager<embedded_migrations::diesel::PgConnection>>`
required because of the requirements on the impl of `std::marker::Send` for `&r2d2::PooledConnection<embedded_migrations::diesel::r2d2::ConnectionManager<embedded_migrations::diesel::PgConnection>>`
required because of the requirements on the impl of `std::marker::Send` for `std::sync::Mutex<&r2d2::PooledConnection<embedded_migrations::diesel::r2d2::ConnectionManager<embedded_migrations::diesel::PgConnection>>>`

Apparently I can't pass reference to a connection?

That error is due to a Diesel type. You should file this with that project.