| Safe Haskell | None |
|---|---|
| Language | Haskell2010 |
Ouroboros.Consensus.Storage.LeiosDB.Impl.SQLite.Connection
Description
Opening, configuring and closing connections to the LeiosDB partition
files, and Conn: a reader's (or the writer's) pair of connections with
their prepared statements.
Synopsis
- initialiseLeiosDbFiles ∷ HasCallStack ⇒ FilePath → FilePath → IO ()
- openRawConnection ∷ HasCallStack ⇒ FilePath → IO Database
- withReadOnlyConn ∷ HasCallStack ⇒ FilePath → (Database → IO a) → IO a
- closeChecked ∷ HasCallStack ⇒ Database → IO ()
- data Conn = Conn {
- conVolDb ∷ !Database
- connVolStmts ∷ !VolStmts
- connTracer ∷ !(Tracer IO TraceLeiosDb)
- connStats ∷ !(StrictTVar IO LeiosDbStats)
- conImmDb ∷ !Database
- connImmStmts ∷ !ImmStmts
- mkConn ∷ Tracer IO TraceLeiosDb → StrictTVar IO LeiosDbStats → Database → Database → IO Conn
- finalizeConnStmts ∷ Conn → IO ()
- closeConn ∷ Conn → IO ()
- dbWithWriteTransaction ∷ HasCallStack ⇒ Conn → IO a → IO a
Partition files
initialiseLeiosDbFiles ∷ HasCallStack ⇒ FilePath → FilePath → IO () Source #
Create the volatile and immutable LeiosDB partition files if missing and apply their schemas.
openRawConnection ∷ HasCallStack ⇒ FilePath → IO Database Source #
Open a read-write connection to an existing partition file, whose schema
initialiseLeiosDbFiles has already applied.
withReadOnlyConn ∷ HasCallStack ⇒ FilePath → (Database → IO a) → IO a Source #
Open a strictly read-only connection, for seeding DB statistics.
closeChecked ∷ HasCallStack ⇒ Database → IO () Source #
sqlite3_close refuses -- and would silently leak the connection -- if
statements are still open; a caller that failed to finalize must hear it.
Connections with prepared statements
Constructors
| Conn | |
Fields
| |
mkConn ∷ Tracer IO TraceLeiosDb → StrictTVar IO LeiosDbStats → Database → Database → IO Conn Source #
finalizeConnStmts ∷ Conn → IO () Source #
Finalize the statements of a Conn, leaving its connections open, for a
caller that closes those itself.
closeConn ∷ Conn → IO () Source #
Finalize the statements of a Conn, then close both its connections.
dbWithWriteTransaction ∷ HasCallStack ⇒ Conn → IO a → IO a Source #
A writing transaction: BEGIN IMMEDIATE, taking the write lock up front.
A deferred transaction that reads before it writes has to upgrade its lock,
and in WAL mode that upgrade fails with SQLITE_BUSY_SNAPSHOT whenever
another connection committed in between. That status is not serviced by the
busy handler and cannot be retried at the statement level, because the
transaction's snapshot is stale for good: the only remedy is to roll back and
start over. Taking the lock at BEGIN removes the upgrade, so contention
surfaces here instead, where waiting actually resolves it.