Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/Database/LSMTree/Internal/MergeSchedule.hs
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ import System.FS.BlockIO.API (HasBlockIO)
-------------------------------------------------------------------------------}

data AtLevel a = AtLevel LevelNo a
deriving stock Show
deriving stock (Show, Eq)

data MergeTrace =
TraceFlushWriteBuffer
Expand All @@ -118,7 +118,7 @@ data MergeTrace =
-- | This is traced at the latest point the merge could complete.
| TraceExpectCompletedMerge
RunNumber
deriving stock Show
deriving stock (Show, Eq)

{-------------------------------------------------------------------------------
Table content
Expand Down
20 changes: 13 additions & 7 deletions src/Database/LSMTree/Internal/Unsafe.hs
Original file line number Diff line number Diff line change
Expand Up @@ -140,13 +140,15 @@ import Database.LSMTree.Internal.Paths (SessionRoot (..),
SnapshotMetaDataFile (..), SnapshotName)
import qualified Database.LSMTree.Internal.Paths as Paths
import Database.LSMTree.Internal.Range (Range (..))
import Database.LSMTree.Internal.RawBytes (RawBytes)
import Database.LSMTree.Internal.Readers (OffsetKey (..))
import qualified Database.LSMTree.Internal.Readers as Readers
import Database.LSMTree.Internal.Run (Run)
import qualified Database.LSMTree.Internal.Run as Run
import Database.LSMTree.Internal.RunNumber
import Database.LSMTree.Internal.Serialise (ResolveSerialisedValue,
SerialisedBlob (..), SerialisedKey, SerialisedValue)
SerialisedBlob (..), SerialisedKey (SerialisedKey),
SerialisedValue)
import Database.LSMTree.Internal.Snapshot
import Database.LSMTree.Internal.Snapshot.Codec
import Database.LSMTree.Internal.UniqCounter
Expand Down Expand Up @@ -206,7 +208,7 @@ data LSMTreeTrace =
-- | Cursors are identified by a unique number.
CursorId
CursorTrace
deriving stock Show
deriving stock (Show, Eq)

-- | Sessions are identified by the path to their root directory.
newtype SessionId = SessionId FsPath
Expand Down Expand Up @@ -243,7 +245,7 @@ data SessionTrace =

-- | We are retrieving blobs.
| TraceRetrieveBlobs Int
deriving stock Show
deriving stock (Show, Eq)

-- | Trace messages related to tables.
data TableTrace =
Expand Down Expand Up @@ -313,7 +315,7 @@ data TableTrace =
-- | INTERNAL: debug traces for the merge schedule
| TraceMerge (AtLevel MergeTrace)
#endif
deriving stock Show
deriving stock (Show, Eq)

contramapTraceMerge :: Monad m => Tracer m TableTrace -> Tracer m (AtLevel MergeTrace)
#ifdef DEBUG_TRACES
Expand All @@ -333,7 +335,9 @@ data CursorTrace =
| TraceNewCursor
-- | The parent table
TableId
OffsetKey
-- | The optional serialised key that is used as the initial offset for
-- the cursor.
(Maybe RawBytes)

-- | We are closing the cursor. A 'TraceClosedCursor' message should follow
-- if successful.
Expand All @@ -352,7 +356,7 @@ data CursorTrace =
Int
-- | Actual number of entries read.
Int
deriving stock Show
deriving stock (Show, Eq)

{-------------------------------------------------------------------------------
Session
Expand Down Expand Up @@ -1426,7 +1430,9 @@ newCursor !resolve !offsetKey t = withKeepTableOpen t $ \tEnv -> do
cursorId <- uniqueToCursorId <$>
incrUniqCounter (tableSessionUniqCounter t)
let cursorTracer = TraceCursor cursorId `contramap` lsmTreeTracer cursorSession
traceWith cursorTracer $ TraceNewCursor (tableId t) offsetKey
traceWith cursorTracer $ TraceNewCursor (tableId t) $ case offsetKey of
NoOffsetKey -> Nothing
OffsetKey (SerialisedKey bytes) -> Just bytes

-- We acquire a read-lock on the session open-state to prevent races, see
-- 'sessionOpenTables'.
Expand Down
6 changes: 3 additions & 3 deletions test/golden-file-data/tracer/golden_traceMessages.golden
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@ TraceTable (TableId 0) (TraceUpdated 1)
TraceTable (TableId 0) (TraceLookups 1)
TraceTable (TableId 0) (TraceLookups 1)
TraceTable (TableId 0) (TraceRangeLookup (FromToExcluding (SerialisedKey [0,0,0,0,0,0,0,0]) (SerialisedKey [0,0,0,0,0,0,0,3])))
TraceCursor (CursorId 2) (TraceNewCursor (TableId 0) (OffsetKey (SerialisedKey [0,0,0,0,0,0,0,0])))
TraceCursor (CursorId 2) (TraceNewCursor (TableId 0) (Just [0,0,0,0,0,0,0,0]))
TraceCursor (CursorId 2) (TraceCreatedCursor (SessionId session-dir))
TraceCursor (CursorId 2) (TraceReadingCursor 500)
TraceCursor (CursorId 2) (TraceReadCursor 500 2)
TraceCursor (CursorId 2) TraceCloseCursor
TraceCursor (CursorId 2) TraceClosedCursor
TraceCursor (CursorId 3) (TraceNewCursor (TableId 0) (OffsetKey (SerialisedKey [0,0,0,0,0,0,0,1])))
TraceCursor (CursorId 3) (TraceNewCursor (TableId 0) (Just [0,0,0,0,0,0,0,1]))
TraceCursor (CursorId 3) (TraceCreatedCursor (SessionId session-dir))
TraceCursor (CursorId 3) (TraceReadingCursor 2)
TraceCursor (CursorId 3) (TraceReadCursor 2 1)
Expand Down Expand Up @@ -66,7 +66,7 @@ TraceTable (TableId 0) TraceCloseTable
TraceTable (TableId 0) TraceClosedTable
TraceTable (TableId 21) (TraceNewTable (TableConfig {confMergePolicy = LazyLevelling, confMergeSchedule = Incremental, confSizeRatio = Four, confWriteBufferAlloc = AllocNumEntries 20000, confBloomFilterAlloc = AllocRequestFPR 1.0e-3, confFencePointerIndex = OrdinaryIndex, confDiskCachePolicy = DiskCacheAll, confMergeBatchSize = MergeBatchSize 20000}))
TraceTable (TableId 21) (TraceCreatedTable (SessionId session-dir) (TableConfig {confMergePolicy = LazyLevelling, confMergeSchedule = Incremental, confSizeRatio = Four, confWriteBufferAlloc = AllocNumEntries 20000, confBloomFilterAlloc = AllocRequestFPR 1.0e-3, confFencePointerIndex = OrdinaryIndex, confDiskCachePolicy = DiskCacheAll, confMergeBatchSize = MergeBatchSize 20000}))
TraceCursor (CursorId 23) (TraceNewCursor (TableId 21) NoOffsetKey)
TraceCursor (CursorId 23) (TraceNewCursor (TableId 21) Nothing)
TraceCursor (CursorId 23) (TraceCreatedCursor (SessionId session-dir))
TraceSession (SessionId session-dir) TraceCloseSession
TraceCursor (CursorId 23) TraceCloseCursor
Expand Down