-
-
Notifications
You must be signed in to change notification settings - Fork 133
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
Dream.sql, reentrancy and sessions #332
Comments
Surprise deadlocks are definitely not reasonable, especially not exposing them to a newcomer to webdev! Thanks for the issue! I've further simplified the example (in terms of triggering the inner code that is causing the problem) to let () =
Dream.run
@@ Dream.logger
@@ Dream.sql_pool ~size:100 "sqlite3:db.sqlite"
@@ Dream.sql_sessions
@@ fun request ->
Dream.sql request @@ fun _ ->
Dream.sql request @@ fun _ ->
Dream.respond "unreachable" What's happening here is that the Sqlite3 DB driver does not support concurrent connections AFAICT, so the inner call to I think the more important question, unsimplifying the example, is do you need to have the Assuming your application can still be correct if it calls |
I have indeed changed my code to call Thanks a lot for the PR, and for your work on Dream in general. |
Great! I will merge the PR for now to help mitigate this kind of situation partially, and also note bigger issues with updating the session atomically for future work. |
If you could sketch out a scenario where the session has to be updated atomically, it would be helpful. But no need -- I'll try to come up with something compelling eventually :) |
I made the mistake of calling
Dream.set_session_field
from the callback passed toDream.sql
. Since I had configured sessions to be stored in the SQL database,Dream.set_session_field
itself calledDream.sql
, immediately leading to a deadlock for this client. Below is a minimal reproducible example.As a newcomer to web development, I am not sure whether this behavior is considered reasonable or not. If it is, perhaps it should be mentioned in the documentation.
The text was updated successfully, but these errors were encountered: