mirror of
https://github.com/unisonweb/unison.git
synced 2024-09-20 14:57:41 +03:00
commit in runWriteTransaction
This commit is contained in:
parent
53beb4ab3b
commit
50ae4af63c
@ -85,7 +85,6 @@ runTransaction :: MonadIO m => Connection -> Transaction a -> m a
|
||||
runTransaction conn (Transaction f) = liftIO do
|
||||
uninterruptibleMask \restore -> do
|
||||
Connection.begin conn
|
||||
result <-
|
||||
-- Catch all exceptions (sync or async), because we want to ROLLBACK the BEGIN no matter what.
|
||||
trySyncOrAsync @_ @SomeException (restore (f conn)) >>= \case
|
||||
Left exception -> do
|
||||
@ -95,7 +94,7 @@ runTransaction conn (Transaction f) = liftIO do
|
||||
restore (threadDelay 100_000)
|
||||
runWriteTransaction_ restore 200_000 conn (f conn)
|
||||
_ -> throwIO exception
|
||||
Right result -> pure result
|
||||
Right result -> do
|
||||
Connection.commit conn
|
||||
pure result
|
||||
{-# SPECIALIZE runTransaction :: Connection -> Transaction a -> IO a #-}
|
||||
@ -176,7 +175,9 @@ runWriteTransactionIO conn f =
|
||||
runWriteTransaction_ :: (forall x. IO x -> IO x) -> Int -> Connection -> IO a -> IO a
|
||||
runWriteTransaction_ restore microseconds conn transaction = do
|
||||
keepTryingToBeginImmediate restore conn microseconds
|
||||
restore transaction `onException` ignoringExceptions (Connection.rollback conn)
|
||||
result <- restore transaction `onException` ignoringExceptions (Connection.rollback conn)
|
||||
Connection.commit conn
|
||||
pure result
|
||||
|
||||
-- @BEGIN IMMEDIATE@ until success.
|
||||
keepTryingToBeginImmediate :: (forall x. IO x -> IO x) -> Connection -> Int -> IO ()
|
||||
|
Loading…
Reference in New Issue
Block a user