Terms in this set (9)
Atomicity: states that database modiﬁcations must follow an all or nothing rule.
Consistency: states that only valid data will be written to the database.
Isolation: requires that multiple transactions occurring at the same time not impact each others execution.
Durability: ensures that any transaction committed to the database will not be lost.
A transaction either COMMIT after completing all its actions or ABORT after executing some actions.
A user can think of a transaction as always executing all its actions in one step, or not executing any actions at all.
DBMS logs all actions so that it can undo the actions of aborted transactions.
Conﬂicts of interleaved execution
The diﬀerent schedules of transactions might ignore the operations ﬁnalized by other transactions.
Reason: conﬂicts with Read/Write operations
Conﬂicts are caused by the isolation property of transactions.
The isolation property might cause an anomaly in the database.
Four possible combination of Read/Write operations:
Read/Read, (Reading does not alter the state of the database. Just reading is always safe!)
Strict Two Phase-Locking (2PL)
We deﬁne two locks on objects, Shared and Exclusive.
We denote with X(A) an exclusive lock on an object A. We denote with S(A) a shared lock.
The Strict 2PL scheduler ensures that no anomalies arise from the interleaved executions of the transactions.
A transaction that wants to read an object requests a shared lock.
A transaction that wants to write an object requests an exclusive lock.
A transaction is allowed to release all the locks only after it commits or aborts (so rollback is executed before another transaction can use the data).
Locking on tables
Query for T1:
SELECT type FROM ships WHERE firepower = 1500
Query for T2
UPDATE ships SET type = "Star Destroyer" WHERE firepower >= 1500
Set a shared lock for T1 on the entire table, or set a shared lock only on the rows with firepower = 1500 (more concurrency).
Transaction in PostgreSQL
BEGIN TRANSACTION begins a transaction.
ISOLATION LEVEL sets the isolation level as seen above.
COMMIT commits the transaction.
BEGIN TRANSACTION ISOLATION LEVEL
WHERE firepower = 1500;
Build a graph where each node is mapped to a transaction
An arrow starts from T1 and points to T2 if T1 is waiting for a lock to be released by T2.
If we have a cycle in such graph then there is a deadlock.
The DBMS scheduler aborts transactions involved in a deadlock to free their locks.
Neem de presentatie door want dit is veel te weinig en goeie filmpjes op youtube is niet mogelijk.
OTHER SETS BY THIS CREATOR
Week 1 - Quiz
Week 5 - Notes
Week 4 - Notes
Week 3 - Notes
THIS SET IS OFTEN IN FOLDERS WITH...
NoSQL and Graph Databases