Atomicity of PostgreSQL Interactions¶
Both the webapi and the node which populates the database operate on the database within a database transaction. All operations on the database from Haskell code is done in a function which has a type signatures of :
ReaderT SqlBackend m a
Any function without the
ReaderT SqlBackend component will not be able to access the database
and any attempt to access the database without the required type signature will result in a compile
error at compile time.
All functions with the required file type are run with the function provided by Haskell’s Persistent library:
runSqlConnWithIsolation action backend Serializable
runSqlConnWithIsolationis the function that runs the provided
actionon a connection to the database within a database transaction.
actionis the action to be performed on the database (eg write or query).
backendcontains the database connection data.
Serializablespecifies the transaction isolation level.
In this case the
Serializable transaction isolation level is used which is the
maximum level of transaction isolation.