| Safe Haskell | None |
|---|---|
| Language | Haskell2010 |
Ouroboros.Consensus.Storage.LeiosDB.Impl.SQLite.WriteQueue
Description
The submission side of the single writer: the jobs it serves and the
bounded queue that carries them. The worker that drains the queue is
startWriter.
Synopsis
- data WriteJob
- = WriteEbPoint !LeiosPoint !BytesSize !(WriteResult ())
- | WriteEbBody !LeiosPoint !LeiosEb !(WriteResult CompletedEbs)
- | WriteTxs ![(TxHash, ByteString)] !(WriteResult CompletedEbs)
- | Flush !(WriteResult ())
- | PinEb ![EbHash] !(WriteResult ())
- | MarkCopied ![EbHash] !(WriteResult ())
- | GcMark !SlotNo !(WriteResult ())
- | Shutdown !(WriteResult ())
- type WriteResult a = StrictTMVar IO (Either SomeException a)
- data WriteQueue = WriteQueue {}
- submitJob ∷ HasCallStack ⇒ WriteQueue → (WriteResult a → WriteJob) → IO (Promise IO a)
- describeJob ∷ WriteJob → String
- failJob ∷ SomeException → WriteJob → IO ()
- maxJobsBetweenMaintenance ∷ Int
- writerQueueDepth ∷ Natural
Documentation
One queued write, carrying the variable its result lands in.
The insert jobs come from LeiosDbWriter, the rest from the handle's
promote/GC entry points. One worker running them all is what makes the
single-writer property total: no two in-process connections ever contend
for a write lock on the volatile partition. Sweeping is not a job at all
-- the worker does it between jobs; see startWriter.
Constructors
| WriteEbPoint | |
Fields
| |
| WriteEbBody | |
Fields
| |
| WriteTxs | |
Fields
| |
| Flush !(WriteResult ()) | Does nothing; awaiting it after the queue's FIFO order means every write submitted before it has landed. |
| PinEb | Pin EBs for promotion; see |
Fields
| |
| MarkCopied | The volatile half of a copy: the EB is in the immutable partition
now, so its volatile rows are evictable. Submitted by |
Fields
| |
| GcMark | The GC MARK phase; see |
Fields
| |
| Shutdown !(WriteResult ()) | Stop the worker: awaiting it after the queue's FIFO order means every write submitted before it has landed and the connections are closed. |
type WriteResult a = StrictTMVar IO (Either SomeException a) Source #
data WriteQueue Source #
The writer's submission side: the job queue, and -- once the worker has stopped -- the exception every submission throws instead of queueing.
Constructors
| WriteQueue | |
submitJob ∷ HasCallStack ⇒ WriteQueue → (WriteResult a → WriteJob) → IO (Promise IO a) Source #
Hand a job to the writer; the Promise waits for its result. Blocks
only while the queue is full, which is the backpressure -- and which is
traced, since it is the one thing about the writer that no other trace
reports: every producer is now waiting on it.
Checking the seal and queueing are one transaction, so after the worker seals the queue no job can slip in unserved: submission throws the worker's parting exception instead -- also waking any submitter that was blocked on a full queue.
describeJob ∷ WriteJob → String Source #
Name a job for LeiosDbWriteException: what it is and what it is about,
never its payload.
failJob ∷ SomeException → WriteJob → IO () Source #
Publish the worker's parting exception as a queued job's result.
maxJobsBetweenMaintenance ∷ Int Source #
How many queued jobs the writer serves back-to-back before it takes a turn of maintenance anyway.
Maintenance runs when the queue drains, which is the common case; this is
the floor under a queue that never does. One queue-full: under saturation
maintenance still gets a turn as often as the producers can refill, and
the resulting share (one turn in ) is far above
what copying and eviction ask for -- they are per promoted or expired EB,
not per write. writerQueueDepth + 1TraceLeiosDbStats is where a volatile partition that
still grows would show up.
writerQueueDepth ∷ Natural Source #
Depth of the write queue. One slot per producer that can be mid-write -- each upstream peer's fetch client, the forge, and the maintenance schedulers (copier, sweeper, the ChainDB's GC and promote calls) -- and a little slack. Deliberately shallow: depth beyond that adds no throughput (there is one worker) and only delays the commit-time notifications that gate vote scheduling and chain selection. A producer that outruns the disk blocks on submission, which is the backpressure.