Browse files

Add comment about withTransaction resource leak

  • Loading branch information...
1 parent b5bd9bd commit 116988981aadd8d3cf63e4b745a038e6c8b4f897 @mightybyte committed Jul 18, 2016
Showing with 12 additions and 0 deletions.
  1. +12 −0 src/Snap/Snaplet/PostgresqlSimple.hs
View
12 src/Snap/Snaplet/PostgresqlSimple.hs
@@ -420,17 +420,29 @@ executeMany :: (HasPostgres m, ToRow q)
executeMany template qs = liftPG (\c -> P.executeMany c template qs)
+------------------------------------------------------------------------------
+-- | Be careful that you do not call Snap's `finishWith` function anywhere
+-- inside the function that you pass to `withTransaction`. Doing so has been
+-- known to cause DB connection leaks.
withTransaction :: (HasPostgres m)
=> m a -> m a
withTransaction = withTransactionMode P.defaultTransactionMode
+------------------------------------------------------------------------------
+-- | Be careful that you do not call Snap's `finishWith` function anywhere
+-- inside the function that you pass to `withTransactionLevel`. Doing so has
+-- been known to cause DB connection leaks.
withTransactionLevel :: (HasPostgres m)
=> P.IsolationLevel -> m a -> m a
withTransactionLevel lvl =
withTransactionMode P.defaultTransactionMode { P.isolationLevel = lvl }
+------------------------------------------------------------------------------
+-- | Be careful that you do not call Snap's `finishWith` function anywhere
+-- inside the function that you pass to `withTransactionMode`. Doing so has
+-- been known to cause DB connection leaks.
withTransactionMode :: (HasPostgres m)
=> P.TransactionMode -> m a -> m a
withTransactionMode mode act = withPG $ CIO.block $ do

0 comments on commit 1169889

Please sign in to comment.