Skip to content
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

Send+Sync for connection #131

Open
acasajus opened this issue Dec 2, 2019 · 4 comments
Open

Send+Sync for connection #131

acasajus opened this issue Dec 2, 2019 · 4 comments

Comments

@acasajus
Copy link

acasajus commented Dec 2, 2019

Looking at the docs it says that Send and Sync are not implemented for connection but in your r2d2-odbc crate it is "unsafely" implemented. Can they be implemented in this crate? Or do you allow it under r2d2 because it takes care not to share a connection amongst two threads?

@Koka
Copy link
Owner

Koka commented Jan 23, 2020

Hello, thanks for your question. This needs more deep investigation because it's highly dependent on ODBC driver manager and driver itself whether it's safe to use things concurrently or not. r2d2-odbc is hacky quick'n'dirty implementation, but in this crate we try to do things more safely

@pacman82
Copy link
Contributor

Just a quick comment from the sideline: In general it is unsafe, because it depends on your ODBC configuration wether this is safe or not. I'd suggest to promote a connection without Send + Sync to a connection type with Send + Sync via an unsafe function.

I think the relevant configuration to look at wether this is actually safe, is the threading level. See:
https://stackoverflow.com/questions/4207458/using-unixodbc-in-a-multithreaded-concurrent-setting#4207474

Threading=2 should be fine.

@bbigras
Copy link

bbigras commented Feb 21, 2020

I'm also interested in this. I would love to be able to use this crate with deadpool:
bikeshedder/deadpool#43

I wouldn't mind using bb8 too.

@Koka
Copy link
Owner

Koka commented Feb 21, 2020

Would gladly merge PR implementing the @pacman82 idea.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants