-
Notifications
You must be signed in to change notification settings - Fork 2
[AD-347] Checkpoint & archive Acid DB periodically #366
base: master
Are you sure you want to change the base?
[AD-347] Checkpoint & archive Acid DB periodically #366
Conversation
b310601 to
d616d32
Compare
|
PR description doesn't comply with PR template:
|
ariadne/cardano/src/Ariadne/Wallet/Cardano/WalletLayer/Types.hs
Outdated
Show resolved
Hide resolved
| mkWalletFace :: (Doc -> IO ()) -> WalletFace | ||
| walletInitAction :: IO () | ||
| (mkWalletFace, walletInitAction) = | ||
| (mkWalletFace, walletInitAction, walletAction) = |
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.
This conflicts with #364. One of you will have to resolve some merge conflicts.
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.
#364 has been merged.
ariadne/cardano/src/Ariadne/Wallet/Cardano/WalletLayer/Kernel.hs
Outdated
Show resolved
Hide resolved
ariadne/cardano/src/Ariadne/Wallet/Cardano/Kernel/DB/Util/AcidState.hs
Outdated
Show resolved
Hide resolved
| mkWalletFace :: (Doc -> IO ()) -> WalletFace | ||
| walletInitAction :: IO () | ||
| (mkWalletFace, walletInitAction) = | ||
| (mkWalletFace, walletInitAction, walletAction) = |
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.
#364 has been merged.
ariadne/cardano/src/Ariadne/Wallet/Cardano/Kernel/DB/Util/AcidState.hs
Outdated
Show resolved
Hide resolved
ariadne/cardano/src/Ariadne/Wallet/Cardano/Kernel/DB/Util/AcidState.hs
Outdated
Show resolved
Hide resolved
ariadne/cardano/src/Ariadne/Wallet/Cardano/Kernel/DB/Util/AcidState.hs
Outdated
Show resolved
Hide resolved
ariadne/cardano/src/Ariadne/Wallet/Cardano/Kernel/DB/Util/AcidState.hs
Outdated
Show resolved
Hide resolved
ariadne/cardano/src/Ariadne/Wallet/Cardano/WalletLayer/Types.hs
Outdated
Show resolved
Hide resolved
d616d32 to
29f0229
Compare
|
CI failed, btw. |
7c74c61 to
0f1b7de
Compare
|
Fixed |
| , pwlRollbackBlocks | ||
| :: NewestFirst NE Blund | ||
| -> m () | ||
| , pwlCleanAcidDB |
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.
It's currently in the core API section, but it's not core API. I think it should be a new section.
And actually now I think it is better to make it part of passiveWalletLayerComponent.
buildComponent "Wallet DB cleaner" (async cleanupAcidState) uninterruptibleCancel.
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.
Though @Pastafarianist may disagree, so I'd wait for his comments. I think the fact that wallet layer uses acid-state is its implementation detail and the necessity to run some helper worker is caused solely by this detail, so I like the idea of hiding it inside WalletLayer (and fortunately it's very easy to do, because ComponentM allows you to do equivalent of withAsync).
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.
Totally agree!
I thought about the possibility of hiding Acid DB (and related stuff) behind wallet layer, just thought it can be done as a separate task.
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.
We have some tasks about hiding acid DB behind wallet layer (e. g. AD-306 and AD-493), but they are about hiding stuff that is already visible, i. e. that wasn't hidden when it was added.
pwlCleanAcidDB is a new stuff, so it's better to hide it when it's added, not postpone it. It shouldn't be hard anyway. But let's see what @Pastafarianist thinks first.
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.
@gromakovsky I agree. Cleanup is an implementation detail and certainly not a part of core API.
ariadne/cardano/src/Ariadne/Wallet/Cardano/Kernel/DB/Util/AcidState.hs
Outdated
Show resolved
Hide resolved
dniku
left a comment
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.
Mostly stylistic stuff, but the one about misindented comment is significant. Also, please resolve conflicts as many have accumulated.
| -- It is going to call msPutBackendErrorToUI and rethrow exception, if something goes wrong | ||
| linkUI serviceThread $ msPutBackendErrorToUI uiFace | ||
| uiAction | ||
| withAsync serviceAction $ \serviceThread -> do |
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.
Indentation is mismatched between this line and the previous line. I'm not certain why this block has to be indented 2 spaces further, but it doesn't seem to cause any bugs. Anyway, please either indent the comment or dedent the block.
|
|
||
| import Control.Monad.Except | ||
| import Data.Acid (Update) | ||
| import Control.Monad.Except (Except, runExcept, throwError, withExcept) |
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.
Kudos for explicit imports.
| void $ flip catchAny (\e -> putStrLn @Text $ "Got error while cleaning up archive: " <> show e) $ do | ||
| removed <- liftIO $ cleanupOldAcidArchives path numberOfStoredArchives | ||
| writeLog Debug $ "Removed " <> pretty removed <> " old archive files" | ||
| pass |
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.
Redundant pass?
| cleanupOldAcidArchives | ||
| :: FilePath -- ^ path with stored files | ||
| -> Int -- how many files should be stored | ||
| -> IO Int -- how many files have been deleted |
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.
Seems like this function is used only once, and hence it could go into the where block under cleanupAcidState.
| , pwlRollbackBlocks | ||
| :: NewestFirst NE Blund | ||
| -> m () | ||
| , pwlCleanAcidDB |
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.
@gromakovsky I agree. Cleanup is an implementation detail and certainly not a part of core API.
| => ProtocolMagic | ||
| -> FilePath | ||
| -> (PassiveWalletLayer m -> Kernel.PassiveWallet -> IO a) | ||
| -> IO a |
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.
Due to a decision by @manpages, we are moving to 2-space indentation. This is going to become mandatory after SRK-119 is resolved. Furthermore, indentation in this signature is inconsistent with indentation in withLayerInMemoryStorage. For now, please indent all signatures in this file with 2 spaces.
c95c995 to
4cebbac
Compare
| initializeEverything | ||
| :: forall uiComponents uiFace uiLangFace. | ||
| (Components (AllComponents uiComponents), HasCallStack) | ||
| (Components (AllComponents uiComponents)) |
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.
Why did you delete HasCallStack?
| -- Make custom link to service thread for UI apps. | ||
| -- It is going to call msPutBackendErrorToUI and rethrow exception, if something goes wrong | ||
| linkUI serviceThread $ msPutBackendErrorToUI uiFace | ||
| logDebug logging "Launching the UI..." |
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.
Why? To be honest, I don't understand why there are any changes in this file. Yes, some changes were necessary in a previous version, but now I think this file should remain intact.
Now ariadne periodically makes a checkpoint of AcidState DB, moves old checkpoints to `Archive` path and removes old archives. How often this action is performed and how many archives will be stored in the path is determined by the wallet's configuration and can be overwritten by command line arguments.
1) Use "Time Second" instead of Int in config. 2) Don't expose wallet from PassiveWalletLayer 3) Now the thread which archive Acid DB now is controlled from MainTemplate 4) Other small changes 5) Resolve conflicts with the current master.
This commit fixes Ariadne tests which use wallet config.
Removed one unused constraint tuple and fixed docs
Problem: acid DB cleanup cation should not be exposed outside of the passiveWallet API. Solution: Remove it from PassiveWalletLayer and now the thread which periodically cleans the DB is run when passiveWalletLayerComponent is created.
Added few changes due to review and rebasing to the current master Should be sqashed before merging to master.
Revert unnecessary changes in the file.
f03e5a8 to
7d6cb7e
Compare
Description:
Now Ariadne periodically makes a checkpoint of AcidState DB,
moves old checkpoints to
Archivepath and removes old archives.How often this action is performed and how many archives will be
stored in the path is defined by the wallet's configuration
and can be overwritten by command line arguments.
YT issue: https://issues.serokell.io/issue/AD-347
Checklist: