Skip to content

Commit 4010598

Browse files
committed
LedgerDB.V2: add haddocks for ldbOpenHandlesLock
1 parent 97792c2 commit 4010598

File tree

1 file changed

+13
-0
lines changed
  • ouroboros-consensus/src/ouroboros-consensus/Ouroboros/Consensus/Storage/LedgerDB

1 file changed

+13
-0
lines changed

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

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -458,6 +458,19 @@ data LedgerDBEnv m l blk = LedgerDBEnv
458458
, ldbResolveBlock :: !(ResolveBlock m blk)
459459
, ldbQueryBatchSize :: !QueryBatchSize
460460
, ldbOpenHandlesLock :: !(RAWLock m LDBLock)
461+
-- ^ While holding a read lock (at least), all handles in the 'ldbSeq' are
462+
-- guaranteed to be open. During this time, the handle can be duplicated and
463+
-- then be used independently, see 'getStateRef' and 'withStateRef'.
464+
--
465+
-- Therefore, closing any handles which were previously in 'ldbSeq' requires
466+
-- acquiring a write lock. Concretely, both of the following approaches are
467+
-- fine:
468+
--
469+
-- * Modify 'ldbSeq' without any locking, and then close the removed handles
470+
-- while holding a write lock. See e.g. 'closeForkerEnv'.
471+
--
472+
-- * Modify 'ldbSeq' while holding a write lock, and then close the removed
473+
-- handles without any locking.
461474
}
462475
deriving Generic
463476

0 commit comments

Comments
 (0)