Skip to content

Commit 41ca767

Browse files
committed
change isolation rules for offchain
1 parent a3820a8 commit 41ca767

1 file changed

Lines changed: 9 additions & 4 deletions

File tree

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

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ import qualified Cardano.Db as DB
2626
import Cardano.DbSync.Api
2727
import Cardano.DbSync.Api.Types (InsertOptions (..), SyncEnv (..))
2828
import Cardano.DbSync.Config.Types
29+
import qualified Cardano.DbSync.Default as Default
2930
import Cardano.DbSync.OffChain.Http
3031
import Cardano.DbSync.OffChain.Query
3132
import 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

Comments
 (0)