-
Notifications
You must be signed in to change notification settings - Fork 35
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
Properly use new concurrency functions in mysql #34
Comments
It is certainly a challenge! When I fixed the Yesod scaffolding to use the new functions, I had to pass several settings to the I'd love to see some proposals! |
I can't recall if the C library wants you to use a connection within the same thread at all times (i.e. if it's safe to use the same connection in different threads over time). I do recall thinking over this problem years ago when I first discovered the issue in One benefit of a monad would be that it could include safe handling of connection pooling when using transactions, which would also help make the story for concurrency better. |
I had segfaults in my program and managed to track it to this concurrency matter. I wrote a wrapper to allow all database communication to be executed in a properly initialised bound thread. I use it as such: import Database.MySQL (connected, withConnection)
...
connected connInfo $ \c -> do
r <- withConnection c $ \conn -> query conn q params
... |
Now that
mysql
finally has the proper concurrency fixes, downstream libraries need to start using the concurrency-related init functions (initLibrary
andinitThread
) to get full, safe concurrency from MySQL at the C level.The changes are here: https://github.com/paul-rouse/mysql/pull/15/files
Making a safe, easy-to-use Haskell API that includes these may prove challenging however.
The text was updated successfully, but these errors were encountered: