Skip to content

Commit dceb55c

Browse files
committed
Delete readAll functionality in LedgerDB backends
1 parent 6273d72 commit dceb55c

File tree

7 files changed

+2
-63
lines changed

7 files changed

+2
-63
lines changed

ouroboros-consensus/changelog.d/20250904_111212_javier.sagredo_lsm_sc_da.md

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,7 @@ For top level release notes, leave all the headers commented out.
1717
- A bullet item for the Non-Breaking category.
1818
1919
-->
20-
<!--
21-
### Breaking
2220

23-
- A bullet item for the Breaking category.
21+
### Breaking
2422

25-
-->
23+
- Removed the `readAll` functionality from the LedgerDB backends now that it became unnecessary as tables conversion is now streamed.

ouroboros-consensus/src/ouroboros-consensus/Ouroboros/Consensus/Storage/LedgerDB/V1/BackingStore/API.hs

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,6 @@ module Ouroboros.Consensus.Storage.LedgerDB.V1.BackingStore.API
5454

5555
-- * 🧪 Testing
5656
, bsRead
57-
, bsReadAll
5857
) where
5958

6059
import Cardano.Slotting.Slot (SlotNo, WithOrigin (..))
@@ -169,9 +168,6 @@ data BackingStoreValueHandle m keys key values = BackingStoreValueHandle
169168
-- itself is idempotent.
170169
, bsvhRangeRead :: !(ReadHint values -> RangeQuery keys -> m (values, Maybe key))
171170
-- ^ See 'RangeQuery'
172-
, bsvhReadAll :: !(ReadHint values -> m values)
173-
-- ^ Costly read all operation, not to be used in Consensus but only in
174-
-- snapshot-converter executable.
175171
, bsvhRead :: !(ReadHint values -> keys -> m values)
176172
-- ^ Read the given keys from the handle
177173
--
@@ -206,7 +202,6 @@ castBackingStoreValueHandle f g h bsvh =
206202
BackingStoreValueHandle
207203
{ bsvhAtSlot
208204
, bsvhClose
209-
, bsvhReadAll = \rhint -> f <$> bsvhReadAll rhint
210205
, bsvhRangeRead = \rhint (RangeQuery prev count) ->
211206
fmap (second (fmap h) . first f) . bsvhRangeRead rhint $ RangeQuery (fmap g prev) count
212207
, bsvhRead = \rhint -> fmap f . bsvhRead rhint . g
@@ -215,7 +210,6 @@ castBackingStoreValueHandle f g h bsvh =
215210
where
216211
BackingStoreValueHandle
217212
{ bsvhClose
218-
, bsvhReadAll
219213
, bsvhAtSlot
220214
, bsvhRangeRead
221215
, bsvhRead
@@ -233,13 +227,6 @@ bsRead store rhint keys = withBsValueHandle store $ \vh -> do
233227
values <- bsvhRead vh rhint keys
234228
pure (bsvhAtSlot vh, values)
235229

236-
bsReadAll ::
237-
MonadThrow m =>
238-
BackingStore m keys key values diff ->
239-
ReadHint values ->
240-
m values
241-
bsReadAll store rhint = withBsValueHandle store $ \vh -> bsvhReadAll vh rhint
242-
243230
-- | A 'IOLike.bracket'ed 'bsValueHandle'
244231
withBsValueHandle ::
245232
MonadThrow m =>

ouroboros-consensus/src/ouroboros-consensus/Ouroboros/Consensus/Storage/LedgerDB/V1/BackingStore/Impl/InMemory.hs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -184,11 +184,6 @@ newInMemoryBackingStore tracer (SnapshotsFS (SomeHasFS fs)) initialization = do
184184
pure $ rangeRead rq values
185185
traceWith tracer $ BSValueHandleTrace Nothing BSVHRangeRead
186186
pure r
187-
, bsvhReadAll = \_ ->
188-
atomically $ do
189-
guardClosed ref
190-
guardHandleClosed refHandleClosed
191-
pure values
192187
, bsvhRead = \_ keys -> do
193188
traceWith tracer $ BSValueHandleTrace Nothing BSVHReading
194189
r <- atomically $ do

ouroboros-consensus/src/ouroboros-consensus/Ouroboros/Consensus/Storage/LedgerDB/V1/BackingStore/Impl/LMDB.hs

Lines changed: 0 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
{-# LANGUAGE OverloadedStrings #-}
1010
{-# LANGUAGE PatternSynonyms #-}
1111
{-# LANGUAGE ScopedTypeVariables #-}
12-
{-# LANGUAGE TypeApplications #-}
1312
{-# LANGUAGE TypeOperators #-}
1413

1514
-- | A 'BackingStore' implementation based on [LMDB](http://www.lmdb.tech/doc/).
@@ -42,7 +41,6 @@ import Data.Functor.Contravariant ((>$<))
4241
import Data.Map (Map)
4342
import qualified Data.Map.Strict as Map
4443
import Data.MemPack
45-
import Data.Proxy
4644
import qualified Data.Set as Set
4745
import qualified Data.Text as Strict
4846
import qualified Database.LMDB.Simple as LMDB
@@ -158,19 +156,6 @@ getDb ::
158156
LMDB.Transaction mode (LMDBMK k v)
159157
getDb (K2 name) = LMDBMK name <$> LMDB.getDatabase (Just name)
160158

161-
readAll ::
162-
(Ord (TxIn l), MemPack (TxIn l), IndexedMemPack idx (TxOut l)) =>
163-
Proxy l ->
164-
idx ->
165-
LMDBMK (TxIn l) (TxOut l) ->
166-
LMDB.Transaction mode (ValuesMK (TxIn l) (TxOut l))
167-
readAll _ st (LMDBMK _ dbMK) =
168-
ValuesMK
169-
<$> Bridge.runCursorAsTransaction'
170-
st
171-
LMDB.Cursor.cgetAll
172-
dbMK
173-
174159
-- | @'rangeRead' rq dbMK@ performs a range read of @rqCount rq@
175160
-- values from database @dbMK@, starting from some key depending on @rqPrev rq@.
176161
--
@@ -659,25 +644,11 @@ mkLMDBBackingStoreValueHandle db = do
659644
Trace.traceWith tracer API.BSVHStatted
660645
pure res
661646

662-
bsvhReadAll :: l EmptyMK -> m (LedgerTables l ValuesMK)
663-
bsvhReadAll st =
664-
Status.withReadAccess dbStatusLock (throwIO LMDBErrClosed) $ do
665-
Status.withReadAccess vhStatusLock (throwIO (LMDBErrNoValueHandle vhId)) $ do
666-
Trace.traceWith tracer API.BSVHRangeReading
667-
res <-
668-
liftIO $
669-
TrH.submitReadOnly trh $
670-
let dbMK = getLedgerTables dbBackingTables
671-
in LedgerTables <$> readAll (Proxy @l) st dbMK
672-
Trace.traceWith tracer API.BSVHRangeRead
673-
pure res
674-
675647
bsvh =
676648
API.BackingStoreValueHandle
677649
{ API.bsvhAtSlot = initSlot
678650
, API.bsvhClose = bsvhClose
679651
, API.bsvhRead = bsvhRead
680-
, API.bsvhReadAll = bsvhReadAll
681652
, API.bsvhRangeRead = bsvhRangeRead
682653
, API.bsvhStat = bsvhStat
683654
}

ouroboros-consensus/src/ouroboros-consensus/Ouroboros/Consensus/Storage/LedgerDB/V2/InMemory.hs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -122,9 +122,6 @@ newInMemoryLedgerTablesHandle tracer someFS@(SomeHasFS hasFS) l = do
122122
let m' = Map.take t . (maybe id (\g -> snd . Map.split g) f) $ m
123123
in pure (LedgerTables (ValuesMK m'), fst <$> Map.lookupMax m')
124124
)
125-
, readAll = \_ -> do
126-
hs <- readTVarIO tv
127-
guardClosed hs pure
128125
, pushDiffs = \st0 !diffs ->
129126
atomically $
130127
modifyTVar

ouroboros-consensus/src/ouroboros-consensus/Ouroboros/Consensus/Storage/LedgerDB/V2/LSM.hs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -283,11 +283,6 @@ newLSMLedgerTablesHandle tracer rr (resKey, t) = do
283283
Map.empty
284284
$ V.zip vec' res
285285
, readRange = implReadRange t
286-
, readAll = \st ->
287-
let readAll' m = do
288-
(v, n) <- implReadRange t st (m, 100000)
289-
maybe (pure v) (fmap (ltliftA2 unionValues v) . readAll' . Just) n
290-
in readAll' Nothing
291286
, pushDiffs = const (implPushDiffs t)
292287
, takeHandleSnapshot = \_ snapshotName -> do
293288
LSM.saveSnapshot

ouroboros-consensus/src/ouroboros-consensus/Ouroboros/Consensus/Storage/LedgerDB/V2/LedgerSeq.hs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -106,10 +106,6 @@ data LedgerTablesHandle m l = LedgerTablesHandle
106106
-- back into the next iteration of the range read. If the function returns
107107
-- Nothing, it means the read returned no results, or in other words, we
108108
-- reached the end of the ledger tables.
109-
, readAll :: !(l EmptyMK -> m (LedgerTables l ValuesMK))
110-
-- ^ Costly read all operation, not to be used in Consensus but only in
111-
-- snapshot-converter executable. The values will be read as if they were from
112-
-- the same era as the given ledger state.
113109
, pushDiffs :: !(forall mk. l mk -> l DiffMK -> m ())
114110
-- ^ Push some diffs into the ledger tables handle.
115111
--

0 commit comments

Comments
 (0)