@@ -157,7 +157,7 @@ withTransactionModeRetry :: TransactionMode -> (SqlError -> Bool) -> Connection
157withTransactionModeRetry mode shouldRetry conn act =
157withTransactionModeRetry mode shouldRetry conn act =
158 mask $ \restore ->
158 mask $ \restore ->
159 retryLoop $ E.try $ do
159 retryLoop $ E.try $ do
160− a <- restore act
160+ a <- restore act `E.onException` rollback_ conn
161 commit conn
161 commit conn
@@ -166,8 +166,7 @@ withTransactionModeRetry mode shouldRetry conn act =
166 beginMode mode conn
166 beginMode mode conn
167 r <- act'
167 r <- act'
168 case r of
168 case r of
169− Left e -> do
169+ Left e ->
171 case fmap shouldRetry (E.fromException e) of
170 case fmap shouldRetry (E.fromException e) of
172 Just True -> retryLoop act'
171 Just True -> retryLoop act'
173 _ -> E.throwIO e
172 _ -> E.throwIO e