@@ -26,6 +26,7 @@ import qualified Cardano.Db as DB
2626import Cardano.DbSync.Api
2727import Cardano.DbSync.Api.Types (InsertOptions (.. ), SyncEnv (.. ))
2828import Cardano.DbSync.Config.Types
29+ import qualified Cardano.DbSync.Default as Default
2930import Cardano.DbSync.OffChain.Http
3031import Cardano.DbSync.OffChain.Query
3132import qualified Cardano.DbSync.OffChain.Vote.Types as Vote
@@ -248,9 +249,11 @@ runFetchOffChainPoolThread syncEnv = do
248249 threadSyncEnv = syncEnv {envDbEnv = dbEnv}
249250 forever $ do
250251 tDelay
251- -- load the offChain vote work queue using the db
252+ -- Determine isolation level based on sync state (dynamic optimization)
253+ mIsolationLevel <- Default. determineIsolationLevel syncEnv
254+ -- Use transaction runner with dynamic isolation level to eliminate redundant BEGIN/COMMIT
252255 _ <-
253- DB. runDbDirectLogged trce dbEnv $
256+ DB. runDbTransLogged trce dbEnv mIsolationLevel $
254257 loadOffChainPoolWorkQueue trce (envOffChainPoolWorkQueue threadSyncEnv)
255258 poolq <- atomically $ flushTBQueue (envOffChainPoolWorkQueue threadSyncEnv)
256259 manager <- Http. newManager tlsManagerSettings
@@ -284,9 +287,11 @@ runFetchOffChainVoteThread syncEnv = do
284287 -- Use the thread-specific SyncEnv for all operations
285288 forever $ do
286289 tDelay
287- -- load the offChain vote work queue using the db
290+ -- Determine isolation level based on sync state (dynamic optimization)
291+ mIsolationLevel <- Default. determineIsolationLevel syncEnv
292+ -- Use transaction runner with dynamic isolation level to eliminate redundant BEGIN/COMMIT
288293 _ <-
289- DB. runDbDirectLogged trce dbEnv $
294+ DB. runDbTransLogged trce dbEnv mIsolationLevel $
290295 loadOffChainVoteWorkQueue trce (envOffChainVoteWorkQueue threadSyncEnv)
291296 voteq <- atomically $ flushTBQueue (envOffChainVoteWorkQueue threadSyncEnv)
292297 now <- liftIO Time. getPOSIXTime
0 commit comments