-
Notifications
You must be signed in to change notification settings - Fork 6
Introduce on-demand connection acquisition mode #80
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
base: master
Are you sure you want to change the base?
Conversation
75872bf to
d23da34
Compare
d23da34 to
8feaea0
Compare
5d785ed to
b66c218
Compare
f43490c to
13f7d83
Compare
13f7d83 to
992fb55
Compare
crtschin
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice work! I didn't spot anything particularly wrong, just have a few questions. I do think this warrants a bit more documentation to the intended usage or intuition behind these connection modes.
|
Oh, I was reviewing an older commit. That sucks, the line numbers in my review don't match. |
crtschin
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Previously reviewed an old commit, moved some comments around and also took a look at newer changes.
| -- check if the predicate allows for the restart | ||
| guard $ f err n | ||
| -- Note: below functions that modify transaction state need to not be | ||
| -- interruptible so we don't end up in unexpected transaction state. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think we preserve this currently.
getConnectionAcquisitionModeusesreadMVarwhich is interruptible.runQuerycontainstakeMVarwhich is also interruptible.
Both of these imply the uninterruptibleMask will hang if an exception lands while waiting on those blocking functions, (which implies deadlocks if the action we're waiting on was the one that caused the exception). Though I think this is fine as long as connections are never used concurrently by multiple threads.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We do, that's exactly what uninterruptibleMask does (which you wrote later in the comment, so I'm confused about the first sentence 🤔 ).
Good point about a potential dead lock, I narrowed down the scope of uninterruptibleMask, it should be fine now.
Raveline
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks generally good to me, though the heavy use of uninterruptibleMask is somewhat scary. As Curtis pointed to in his own review, we could end up with some never-ending, unkillable threads if a takeMVar hangs (though I don't see a particular reason why it would).
The rationale you offer is that it guarantees "we don't end up in unexpected transaction state", but I would argue this should not be a responsability of the library, but rather of client code. I do believe a simple mask_ (as postgresql-simple use for transactions) would be more than enough, but since there was already usage of uninterruptableMask_ before this PR, I suppose this can be considered as already having been battle-tested to some extent.
No description provided.