Skip to content
This repository has been archived by the owner on Aug 18, 2020. It is now read-only.

Commit

Permalink
Merge #3973 #3979
Browse files Browse the repository at this point in the history
3973: RCD-43 cherry picks r=karknu a=karknu

## Description

Cherry pick RCD-43 fixes from release/2.0.0.

<!--- A brief description of this PR and the problem is trying to solve -->

## Linked issue
https://iohk.myjetbrains.com/youtrack/issue/RCD-43
<!--- Put here the relevant issue from YouTrack -->



3979: [DEVOPS-1134] use text backend for conenctScripts logging config (#3856) r=disassembler a=disassembler

(cherry picked from commit b49b9de)

## Description

<!--- A brief description of this PR and the problem is trying to solve -->

## Linked issue

<!--- Put here the relevant issue from YouTrack -->



Co-authored-by: Erik de Castro Lopo <erikd@mega-nerd.com>
Co-authored-by: Karl Knutsson <karl.knutsson@iohk.io>
Co-authored-by: Kosyrev Serge <serge.kosyrev@iohk.io>
Co-authored-by: Duncan Coutts <duncan.coutts@iohk.io>
Co-authored-by: Samuel Leathers <disasm@gmail.com>
  • Loading branch information
6 people committed Dec 21, 2018
3 parents 121eddb + 5d6c0d4 + 43a359f commit c7330a0
Show file tree
Hide file tree
Showing 7 changed files with 42 additions and 8 deletions.
1 change: 1 addition & 0 deletions db/cardano-sl-db.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@ library
, ekg-core
, ether >= 0.5
, exceptions
, extra
, filepath
, formatting
, lens
Expand Down
16 changes: 12 additions & 4 deletions db/src/Pos/DB/Block/Epoch.hs
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ import Data.Binary (decode, encode)
import qualified Data.ByteString.Char8 as BS
import qualified Data.ByteString.Lazy as LBS
import Data.Either (partitionEithers)
import Data.List.Extra (chunksOf)
import Formatting (build, int, sformat, shown, (%))
import System.Directory (removeFile)
import System.FilePath ((</>))
Expand Down Expand Up @@ -351,7 +352,12 @@ consolidateOneEpoch ccp epochSlots = do

-- After the check point is written, delete old blunds for the epoch we have just
-- consolidated.
lift $ mapM_ deleteOldBlund sihs
lift $ mapM_ deleter $ chunksOf 1000 sihs
where
deleter :: ConsolidateM ctx m => [SlotIndexHash] -> m ()
deleter xs = do
mapM_ deleteOldBlund xs
sleepSeconds 2

deleteOldBlund :: ConsolidateM ctx m => SlotIndexHash -> m ()
deleteOldBlund (SlotIndexHash _ hh) = do
Expand All @@ -377,16 +383,18 @@ consolidateEpochBlocks fpath xs = ExceptT $ do
(liftIO . hClose)
(\hdl -> do
liftIO $ BS.hPutStr hdl epochFileHeader
mapM (consolidate hdl) xs
mapM (consolidate hdl) $ zip [0 .. ] xs
)
pure $ case partitionEithers ys of
([], zs) -> Right $ epochIndexToOffset zs
(e:_, _) -> Left e
where
consolidate
:: ConsolidateM ctx m
=> Handle -> SlotIndexHash -> m (Either ConsolidateError SlotIndexLength)
consolidate hdl (SlotIndexHash lsi hh) = do
=> Handle -> (Int, SlotIndexHash) -> m (Either ConsolidateError SlotIndexLength)
consolidate hdl (indx, SlotIndexHash lsi hh) = do
when (indx `mod` 1000 == 0) $
sleepSeconds 2
mblund <- getSerializedBlund hh
case mblund of
Nothing ->
Expand Down
10 changes: 10 additions & 0 deletions db/src/Pos/DB/Rocks/Functions.hs
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ import qualified Database.RocksDB as Rocks
import System.Directory (createDirectoryIfMissing, doesDirectoryExist,
removeDirectoryRecursive)
import System.FilePath (takeDirectory, (</>))
import qualified System.Info (os)

import Pos.Binary.Class (Bi, serialize')
import Pos.DB.BatchOp (rocksWriteBatch)
Expand Down Expand Up @@ -82,6 +83,7 @@ openNodeDBs recreate fp = do
let gStatePath = fp </> "gState"
let lrcPath = fp </> "lrc"
let miscPath = fp </> "misc"

mapM_ ensureDirectoryExists
[ blocksDir
, _blockDataDir
Expand All @@ -91,6 +93,11 @@ openNodeDBs recreate fp = do
, lrcPath
, miscPath
]

when (System.Info.os == "darwin") $
-- Prevent indexing of blocks on OSX
ensureEmptyFileExists (fp </> ".metadata_never_index")

_blockIndexDB <- openRocksDB blocksIndexPath
_gStateDB <- openRocksDB gStatePath
_lrcDB <- openRocksDB lrcPath
Expand All @@ -101,6 +108,9 @@ openNodeDBs recreate fp = do
ensureDirectoryExists :: MonadIO m => FilePath -> m ()
ensureDirectoryExists = liftIO . createDirectoryIfMissing True

ensureEmptyFileExists :: MonadIO m => FilePath -> m ()
ensureEmptyFileExists file = liftIO $ withFile file AppendMode (\_ -> return ())

-- | Safely close all databases from 'NodeDBs'.
closeNodeDBs :: MonadIO m => NodeDBs -> m ()
closeNodeDBs NodeDBs {..} =
Expand Down
1 change: 1 addition & 0 deletions lib/src/Pos/Diffusion/Full/Block.hs
Original file line number Diff line number Diff line change
Expand Up @@ -724,6 +724,7 @@ handleStreamStart logTrace logic oq = listenerConv logTrace oq $ \__ourVerInfo n
lift $ traceWith logTrace (Debug, sformat ("handleStreamStart:loop MsgStart, expected MsgStreamUpdate from "%build) nodeId)
return ()
MsgUpdate u -> do
lift $ OQ.clearFailureOf oq nodeId
lift $ traceWith logTrace (Debug, sformat ("handleStreamStart:loop new window "%shown%" from "%build) u nodeId)
loop nodeId conv (msuWindow u)
loop nodeId conv window =
Expand Down
19 changes: 15 additions & 4 deletions log-configs/connect-to-cluster.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,19 @@
rotation:
logLimit: 104857600 # 100MB
keepFiles: 100

loggerTree:
severity: Debug+
files:
- node.pub
- node
severity: Info+

handlers:
- { name: "Public"
, filepath: "pub/node.log"
, logsafety: PublicLogLevel
, severity: Debug+
, backend: FileTextBE }
- { name: "Secret"
, filepath: "node"
, logsafety: SecretLogLevel
, severity: Info+
, backend: FileTextBE }

1 change: 1 addition & 0 deletions nix/.stack.nix/cardano-sl-db.nix

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions pkgs/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -15006,6 +15006,7 @@ license = stdenv.lib.licenses.mit;
, ekg-core
, ether
, exceptions
, extra
, filepath
, formatting
, hedgehog
Expand Down Expand Up @@ -15059,6 +15060,7 @@ directory
ekg-core
ether
exceptions
extra
filepath
formatting
lens
Expand Down

0 comments on commit c7330a0

Please sign in to comment.