Skip to content
This repository was archived by the owner on Oct 12, 2022. It is now read-only.

Conversation

@Haskell-mouse
Copy link
Contributor

@Haskell-mouse Haskell-mouse commented Oct 29, 2018

Description:

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 defined by the wallet's configuration
and can be overwritten by command line arguments.

YT issue: https://issues.serokell.io/issue/AD-347

Checklist:

@Haskell-mouse Haskell-mouse force-pushed the Haskell-mouse/ad-347-acid-state-is-used-improperly branch 3 times, most recently from b310601 to d616d32 Compare October 29, 2018 03:39
@gromakovsky
Copy link
Member

PR description doesn't comply with PR template:

  1. Description is empty, actual description is above it.
  2. Issue link is broken.
  3. Checkmarks are not set.

mkWalletFace :: (Doc -> IO ()) -> WalletFace
walletInitAction :: IO ()
(mkWalletFace, walletInitAction) =
(mkWalletFace, walletInitAction, walletAction) =
Copy link
Contributor

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.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

#364 has been merged.

mkWalletFace :: (Doc -> IO ()) -> WalletFace
walletInitAction :: IO ()
(mkWalletFace, walletInitAction) =
(mkWalletFace, walletInitAction, walletAction) =
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

#364 has been merged.

@dniku dniku changed the title [AD-347] Acid-state is used improperly [AD-347] Checkpoint & archive acid-state periodically Nov 19, 2018
@dniku dniku changed the title [AD-347] Checkpoint & archive acid-state periodically [AD-347] Checkpoint & archive Acid DB periodically Nov 19, 2018
@Haskell-mouse Haskell-mouse force-pushed the Haskell-mouse/ad-347-acid-state-is-used-improperly branch from d616d32 to 29f0229 Compare December 3, 2018 12:44
@gromakovsky
Copy link
Member

CI failed, btw.

@Haskell-mouse Haskell-mouse force-pushed the Haskell-mouse/ad-347-acid-state-is-used-improperly branch from 7c74c61 to 0f1b7de Compare December 3, 2018 17:01
@Haskell-mouse
Copy link
Contributor Author

Fixed

, pwlRollbackBlocks
:: NewestFirst NE Blund
-> m ()
, pwlCleanAcidDB
Copy link
Member

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.

Copy link
Member

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).

Copy link
Contributor Author

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.

Copy link
Member

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.

Copy link
Contributor

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.

@gromakovsky gromakovsky removed the request for review from artemohanjanyan December 10, 2018 12:15
Copy link
Contributor

@dniku dniku left a 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
Copy link
Contributor

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)
Copy link
Contributor

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
Copy link
Contributor

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
Copy link
Contributor

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
Copy link
Contributor

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
Copy link
Contributor

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.

@Haskell-mouse Haskell-mouse force-pushed the Haskell-mouse/ad-347-acid-state-is-used-improperly branch from c95c995 to 4cebbac Compare January 16, 2019 10:51
initializeEverything
:: forall uiComponents uiFace uiLangFace.
(Components (AllComponents uiComponents), HasCallStack)
(Components (AllComponents uiComponents))
Copy link
Member

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..."
Copy link
Member

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.

Haskell-mouse added 8 commits January 26, 2019 00:02
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.
@Haskell-mouse Haskell-mouse force-pushed the Haskell-mouse/ad-347-acid-state-is-used-improperly branch from f03e5a8 to 7d6cb7e Compare January 26, 2019 10:40
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants