Skip to content

Commit

Permalink
undo redundant logging
Browse files Browse the repository at this point in the history
  • Loading branch information
chessai committed Jun 13, 2023
1 parent 12b3fd9 commit c0b2fc3
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 26 deletions.
28 changes: 5 additions & 23 deletions src/Chainweb/Pact/Backend/RelationalCheckpointer.hs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ import Control.Monad
import Control.Monad.Catch
import Control.Monad.IO.Class
import Control.Monad.State (gets)
import GHC.Stack (HasCallStack, prettyCallStack, withFrozenCallStack, callStack)

import Data.ByteString (ByteString)
import qualified Data.ByteString.Short as BS
Expand Down Expand Up @@ -68,7 +67,6 @@ import Chainweb.Pact.Backend.Types
import Chainweb.Pact.Backend.Utils
import Chainweb.Pact.Backend.DbCache (updateCacheStats)
import Chainweb.Pact.Service.Types
import Chainweb.Pact.Types (logError_)
import Chainweb.Utils
import Chainweb.Utils.Serialization
import Chainweb.Version
Expand Down Expand Up @@ -124,7 +122,7 @@ initRelationalCheckpointer' bstate sqlenv loggr v cid = do
{ _cpeCheckpointer =
Checkpointer
{
_cpRestore = doRestore loggr v cid db
_cpRestore = doRestore v cid db
, _cpSave = doSave db
, _cpDiscard = doDiscard db
, _cpGetLatestBlock = doGetLatest db
Expand All @@ -143,8 +141,8 @@ initRelationalCheckpointer' bstate sqlenv loggr v cid = do

type Db = MVar (BlockEnv SQLiteEnv)

doRestore :: HasCallStack => Logger -> ChainwebVersion -> ChainId -> Db -> Maybe (BlockHeight, ParentHash) -> IO PactDbEnv'
doRestore _ v cid dbenv (Just (bh, hash)) = runBlockEnv dbenv $ do
doRestore :: ChainwebVersion -> ChainId -> Db -> Maybe (BlockHeight, ParentHash) -> IO PactDbEnv'
doRestore v cid dbenv (Just (bh, hash)) = runBlockEnv dbenv $ do
setModuleNameFix
setSortedKeys
setLowerCaseTables
Expand All @@ -157,8 +155,7 @@ doRestore _ v cid dbenv (Just (bh, hash)) = runBlockEnv dbenv $ do
setModuleNameFix = bsModuleNameFix .= enableModuleNameFix v bh
setSortedKeys = bsSortedKeys .= pact420Upgrade v bh
setLowerCaseTables = bsLowerCaseTables .= chainweb217Pact After v bh
doRestore loggr _ _ dbenv Nothing = runBlockEnv dbenv $ do
logError_ loggr $ T.unpack $ "temp.chessai: doRestore: resetting tables"
doRestore _ _ dbenv Nothing = runBlockEnv dbenv $ do
clearPendingTxState
withSavepoint DbTransaction $
callDb "doRestoreInitial: resetting tables" $ \db -> do
Expand All @@ -169,22 +166,7 @@ doRestore loggr _ _ dbenv Nothing = runBlockEnv dbenv $ do
exec_ db "DELETE FROM [SYS:Pacts];"
tblNames <- qry_ db "SELECT tablename FROM VersionedTableCreation;" [RText]
forM_ tblNames $ \tbl -> case tbl of
[SText t] -> do
let tblname = case t of { Utf8 x -> T.decodeUtf8 x; }
let interestingTables = [ "free.kdoge_token-table", "free.kadoge_token-table" ]
when (any (\interesting -> interesting `T.isInfixOf` tblname) interestingTables) $ do
stuff <- catch (qry_ db ("SELECT COUNT(*) FROM " <> t <> ";") [RInt]) $ \(SomeException e) -> do
withFrozenCallStack $ do
logError_ loggr $ T.unpack $ "tmp.chessai: When querying "
<> tblname <> " got an error: " <> sshow e
logError_ loggr $ "tmp.chessai: Callstack: " <> prettyCallStack callStack
throwM e
case stuff of
[[SInt count]] -> do
logError_ loggr $ T.unpack $ "tmp.chessai: " <> tblname <> " has " <> sshow count <> " entries."
_ -> do
internalError $ "Didn't get [[SInt count]] from `SELECT COUNT(*) FROM " <> tblname <> ";`"
exec_ db ("DROP TABLE [" <> t <> "];")
[SText t] -> exec_ db ("DROP TABLE [" <> t <> "];")
_ -> internalError "Something went wrong when resetting tables."
exec_ db "DELETE FROM VersionedTableCreation;"
exec_ db "DELETE FROM VersionedTableMutation;"
Expand Down
3 changes: 0 additions & 3 deletions src/Chainweb/Pact/PactService/Checkpointer.hs
Original file line number Diff line number Diff line change
Expand Up @@ -210,9 +210,6 @@ withCheckpointerWithoutRewind target caller act = do
Nothing -> return ()

local (over psCheckpointerDepth succ) $ mask $ \restore -> do
logInfo $ T.unpack $ "withCheckpointerWithoutRewind"
<> ". checkpointerTarget: " <> sshow checkpointerTarget

cenv <- restore $ liftIO $! _cpRestore checkPointer checkpointerTarget

try (restore (act cenv)) >>= \case
Expand Down

0 comments on commit c0b2fc3

Please sign in to comment.