Skip to content

Commit fe06a81

Browse files
committed
Print a warning when node is behind during fixing
1 parent 8766520 commit fe06a81

File tree

1 file changed

+13
-7
lines changed
  • cardano-db-sync/src/Cardano/DbSync

1 file changed

+13
-7
lines changed

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

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,11 @@ module Cardano.DbSync.Sync
2727
) where
2828

2929
import Cardano.Prelude hiding (Meta, Nat, option, (%))
30-
import Prelude (error)
3130

3231
import Control.Tracer (Tracer)
3332

3433
import Cardano.BM.Data.Tracer (ToLogObject (..), ToObject)
35-
import Cardano.BM.Trace (Trace, appendName, logInfo)
34+
import Cardano.BM.Trace (Trace, appendName, logInfo, logWarning)
3635
import qualified Cardano.BM.Trace as Logging
3736

3837
import Cardano.Client.Subscription (subscribe)
@@ -444,13 +443,20 @@ chainSyncClientFix backend tracer fixData = Client.ChainSyncClient $ do
444443
when shouldLog $
445444
liftIO $ logInfo tracer $ mconcat ["Starting fixing Plutus Data ", textShow point]
446445
newLastSize <- liftIO $ updateSizeAndLog lastSize (sizeFixData fds)
447-
pure $ Client.SendMsgFindIntersect
448-
[point]
449-
(Client.ClientStIntersect
446+
let clientStIntersect =
447+
Client.ClientStIntersect
450448
{ Client.recvMsgIntersectFound = \ _pnt _tip -> Client.ChainSyncClient $
451449
pure $ Client.SendMsgRequestNext (clientStNext newLastSize fdOnPoint fdRest) (pure $ clientStNext newLastSize fdOnPoint fdRest)
452-
, Client.recvMsgIntersectNotFound = \_tip -> error "recvMsgIntersectNotFound"
453-
})
450+
, Client.recvMsgIntersectNotFound = \tip -> Client.ChainSyncClient $ do
451+
liftIO $ logWarning tracer $ mconcat
452+
[ "Node can't find block ", textShow point
453+
, ". It's probably behind, at "
454+
, textShow tip, ". Sleeping for 3 mins and retrying.."
455+
]
456+
threadDelay $ 180 * 1_000_000
457+
pure $ Client.SendMsgFindIntersect [point] clientStIntersect
458+
}
459+
pure $ Client.SendMsgFindIntersect [point] clientStIntersect
454460

455461
clientStNext :: Int -> FixData -> FixData -> Client.ClientStNext CardanoBlock (Point CardanoBlock) (Tip CardanoBlock) IO ()
456462
clientStNext lastSize fdOnPoint fdRest =

0 commit comments

Comments
 (0)