Skip to content

Conversation

@arybczak
Copy link
Collaborator

@arybczak arybczak commented Sep 2, 2025

No description provided.

@arybczak arybczak force-pushed the flexible-connections branch 5 times, most recently from 75872bf to d23da34 Compare September 15, 2025 21:00
@arybczak arybczak force-pushed the flexible-connections branch 2 times, most recently from 5d785ed to b66c218 Compare September 17, 2025 01:17
@arybczak arybczak force-pushed the flexible-connections branch from f43490c to 13f7d83 Compare October 6, 2025 16:59
@arybczak arybczak force-pushed the flexible-connections branch from 13f7d83 to 992fb55 Compare October 6, 2025 17:14
@arybczak arybczak marked this pull request as ready for review October 6, 2025 19:20
@arybczak arybczak requested a review from crtschin October 6, 2025 19:23
@arybczak arybczak requested a review from Raveline October 7, 2025 12:21
Copy link
Collaborator

@crtschin crtschin left a 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.

@crtschin
Copy link
Collaborator

crtschin commented Oct 8, 2025

Oh, I was reviewing an older commit. That sucks, the line numbers in my review don't match.

Copy link
Collaborator

@crtschin crtschin left a 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.
Copy link
Collaborator

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.

  • getConnectionAcquisitionMode uses readMVar which is interruptible.
  • runQuery contains takeMVar which 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.

Copy link
Collaborator Author

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.

Copy link

@Raveline Raveline left a 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.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants