Skip to content

Commit b4b722d

Browse files
committed
adjusting runDbTransSilent to not be maybe
1 parent 63e14ff commit b4b722d

4 files changed

Lines changed: 10 additions & 12 deletions

File tree

cardano-db-sync/src/Cardano/DbSync/Api.hs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,7 @@ getInsertOptions :: SyncEnv -> InsertOptions
247247
getInsertOptions = soptInsertOptions . envOptions
248248

249249
getSlotHash :: DB.DbEnv -> SlotNo -> IO [(SlotNo, ByteString)]
250-
getSlotHash backend slotNo = DB.runDbTransSilent backend (Just DB.ReadCommitted) (DB.querySlotHash slotNo)
250+
getSlotHash backend slotNo = DB.runDbTransSilent backend DB.ReadCommitted (DB.querySlotHash slotNo)
251251

252252
hasLedgerState :: SyncEnv -> Bool
253253
hasLedgerState syncEnv =
@@ -258,7 +258,7 @@ hasLedgerState syncEnv =
258258
getDbLatestBlockInfo :: DB.DbEnv -> IO (Maybe TipInfo)
259259
getDbLatestBlockInfo dbEnv = do
260260
runMaybeT $ do
261-
block <- MaybeT $ DB.runDbTransSilent dbEnv (Just DB.ReadCommitted) DB.queryLatestBlock
261+
block <- MaybeT $ DB.runDbTransSilent dbEnv DB.ReadCommitted DB.queryLatestBlock
262262
-- The EpochNo, SlotNo and BlockNo can only be zero for the Byron
263263
-- era, but we need to make the types match, hence `fromMaybe`.
264264
pure $
@@ -324,7 +324,7 @@ mkSyncEnv ::
324324
Bool ->
325325
IO SyncEnv
326326
mkSyncEnv metricSetters trce dbEnv syncOptions protoInfo nw maxLovelaceSupply nwMagic systemStart syncNodeConfigFromFile syncNP runNearTipMigrationFnc isJsonbInSchema = do
327-
dbCNamesVar <- newTVarIO =<< DB.runDbTransSilent dbEnv (Just DB.ReadCommitted) DB.queryRewardAndEpochStakeConstraints
327+
dbCNamesVar <- newTVarIO =<< DB.runDbTransSilent dbEnv DB.ReadCommitted DB.queryRewardAndEpochStakeConstraints
328328
cache <-
329329
if soptCache syncOptions
330330
then
@@ -461,7 +461,7 @@ getLatestPoints env = do
461461
verifySnapshotPoint env snapshotPoints
462462
NoLedger _ -> do
463463
-- Brings the 5 latest.
464-
lastPoints <- DB.runDbTransSilent (envDbEnv env) (Just DB.ReadCommitted) DB.queryLatestPoints
464+
lastPoints <- DB.runDbDirectSilent (envDbEnv env) DB.queryLatestPoints
465465
pure $ mapMaybe convert lastPoints
466466
where
467467
convert (Nothing, _) = Nothing
@@ -516,7 +516,7 @@ getBootstrapInProgress ::
516516
DB.DbEnv ->
517517
IO Bool
518518
getBootstrapInProgress trce bootstrapFlag dbEnv = do
519-
DB.runDbTransSilent dbEnv (Just DB.ReadCommitted) $ do
519+
DB.runDbTransSilent dbEnv DB.ReadCommitted $ do
520520
ems <- DB.queryAllExtraMigrations
521521
let btsState = DB.bootstrapState ems
522522
case (bootstrapFlag, btsState) of

cardano-db-sync/src/Cardano/DbSync/DbEvent.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ runDbSyncTransactionNoLogging ::
8989
m (Either SyncNodeError a)
9090
runDbSyncTransactionNoLogging dbEnv exceptTAction = do
9191
let dbAction = runExceptT exceptTAction
92-
eResult <- liftIO $ try $ DB.runDbTransSilent dbEnv Nothing dbAction
92+
eResult <- liftIO $ try $ DB.runDbTransSilent dbEnv DB.RepeatableRead dbAction
9393
case eResult of
9494
Left (dbErr :: DB.DbSessionError) -> do
9595
pure $ Left $ SNErrDbSessionErr mkSyncNodeCallStack dbErr

cardano-db-sync/src/Cardano/DbSync/Rollback.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ rollbackFromBlockNo syncEnv blkNo = do
6868

6969
prepareRollback :: SyncEnv -> CardanoPoint -> Tip CardanoBlock -> IO (Either SyncNodeError Bool)
7070
prepareRollback syncEnv point serverTip = do
71-
DB.runDbTransSilent (envDbEnv syncEnv) (Just DB.ReadCommitted) $ runExceptT action
71+
DB.runDbTransSilent (envDbEnv syncEnv) DB.ReadCommitted $ runExceptT action
7272
where
7373
trce = getTrace syncEnv
7474

cardano-db/src/Cardano/Db/Run.hs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -90,21 +90,19 @@ runDbTransLogged tracer dbEnv mIsolationLevel action = do
9090
runDbTransSilent ::
9191
MonadUnliftIO m =>
9292
DbEnv ->
93-
Maybe IsolationLevel -> -- Optional isolation level
93+
IsolationLevel ->
9494
DbM a ->
9595
m a
96-
runDbTransSilent dbEnv mIsolationLevel action = do
96+
runDbTransSilent dbEnv isolationLevel action = do
9797
runNoLoggingT $ do
9898
result <- liftIO $ HsqlS.run transactionSession (dbConnection dbEnv)
9999
case result of
100100
Left sessionErr ->
101101
throwIO $ DbSessionError mkDbCallStack ("Database transaction error: " <> formatSessionError sessionErr)
102102
Right dbResult -> pure dbResult
103103
where
104-
isolationLevel = fromMaybe RepeatableRead mIsolationLevel
105104
transactionSession = do
106105
HsqlS.statement () (beginTransactionStmt isolationLevel)
107-
108106
result <- liftIO $ try @SomeException $ runReaderT (runDbM action) dbEnv
109107
case result of
110108
Left err -> do
@@ -272,7 +270,7 @@ runDbStandaloneTransSilent source action = do
272270
HsqlCon.release
273271
( \connection -> do
274272
let dbEnv = createDbEnv connection Nothing Nothing
275-
runDbTransSilent dbEnv Nothing action
273+
runDbTransSilent dbEnv RepeatableRead action
276274
)
277275

278276
-- | Standalone runner without transaction management

0 commit comments

Comments
 (0)