-
Notifications
You must be signed in to change notification settings - Fork 160
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
1847 - add logging to Rollbacks #1877
base: master
Are you sure you want to change the base?
Conversation
62a18e2
to
f761f3c
Compare
deleteEpochLogs <- deleteUsingEpochNo epochN | ||
(deleteBlockCount, blockDeleteLogs) <- deleteTablesAfterBlockId blockId mTxId minIds | ||
whenJust mIsConsumedTxOut $ \_ -> do | ||
querySetNullTxOut trce txOutTableType mTxId |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could we include this in the delete logs summary?
Instead of whenJust here, you could define and use whenJustDefault
. For inspiration, we have similar utilitis in Cardano.DbSync.Util.whenDefault,whenMaybe
@@ -102,106 +131,230 @@ deleteBlocksBlockId trce txOutTableType blockId = do | |||
CMinIdsWrapper (MinIds m1 m2 m3) -> isJust m1 && isJust m2 && isJust m3 | |||
VMinIdsWrapper (MinIds m1 m2 m3) -> isJust m1 && isJust m2 && isJust m3 | |||
|
|||
-- (MinIds m1 m2 m3) isJust m1 && isJust m2 && isJust m3 | |||
mkRollbackSummary :: [(Text, Int64)] -> Text | |||
mkRollbackSummary logs = "\n ----------------------- Rollback Summary: ----------------------- \n" <> formattedLog |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could this become a bit less verbose? For example we could split out logs with 0 deletes and print them in a single row
Count 0: TableA, TableB ...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
updated logs see PR description for updated screenshot
queryBlockSlotNo :: MonadIO m => Word64 -> ReaderT SqlBackend m (Maybe BlockId) | ||
pure $ convertBlockQuery (listToMaybe res) | ||
|
||
queryBlockSlotNo :: MonadIO m => Word64 -> ReaderT SqlBackend m (Maybe (BlockId, Word64)) | ||
queryBlockSlotNo slotNo = do | ||
res <- select $ do | ||
blk <- from $ table @Block | ||
where_ (blk ^. BlockSlotNo ==. just (val slotNo)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could we change the behaviour here, so that it deletes all blocks with greater or equal slot_no?
Currently it finds blocks with the provided slot_no and only if there is one it deletes it and everythiong after it. This is a bit counter-intuitive.
a8816cd
to
8cab25a
Compare
8cab25a
to
0f546d1
Compare
0f546d1
to
dac9abe
Compare
Description
This fixes #1597 #1847
Adding some login to rollbacks for a clearer picture of what is happening.
Also refactored code and moved functionality to
cardano-db/
library.Checklist
fourmolu
on version 0.10.1.0 (which can be run withscripts/fourmolize.sh
)Migrations
If there is a breaking change, especially a big one, please add a justification here. Please elaborate
more what the migration achieves, what it cannot achieve or why a migration is not possible.