Unit 6 Databases, Serialisability, Transactions and 2 Phase Locking Flashcards
What is a database?
A database is an organised collection of data, and is said to be a form of persistent storage.
What are the (ACID) desirable properties of a transaction?
Atomicity - either all steps occur, or none at all
Consistency - The system remains in a consistent state
Isolation - the transaction cannot reveal any part of its state til the transaction is committed.
Durability - once committed the result will persist.
What are the methods of UserTransaction?
begin(), commit(), rollback()
What are the states of a Transaction?
ACTIVE - initial state and while it is executing
PARTIALLY COMMITTED - the state after the final operation has been executed. It remains here while the system writes information to disk.
COMMITTED - the state after successful completion.
FAILED - when normal exection cannot proceed
ABORTED - following rollback() ie all effects are undone and the database is restored to its original state.
Compare the concept of a transaction with that of a coarse grained atomic action. What are their differences and similarities?
Both are as series of steps that need to be implemented ‘as one’. They give the appearance of indivisibility.
The difference is that a transaction has FAILURE ATOMICITY (if it fails it is as though it never happened in the first place, if it succeeds it is made persistent).
What are the possible next states following PARTIALLY COMMITTED for a transaction?
It can progress to COMMITTED once the write completes and the data is made persistent.
Or if there is a problem it will enter FAILED and then ABORTED.
What does the TP system do?
The TP (Transaction Processing) system manages the correct and efficient execution of transactions.
Serialisability - What is a schedule?
A schedule is a preserved, chronological order of operations.
Serialisibility - What is a serial schedule?
A serial schedule is one where the transactions are executed in strict serial order.
Give the definition of serialisibility.
Serialisability is a schedule for a group of transactions that behaves as though it were executed in serial order. ie the results are the same
Is it a problem if serial schedules do not give the same final results for the data object involved?
No it is not. The main concern is whether the data objects are in a consistent state.
What are conflicting operations?
Operations conflict if the order in which they are executed affects the result (e.g read/write)
How is the notion of conflicting operations used to determine whether a schedule is serialisable?
We need to determine what the conflicting operations are. Then we need to determine the order they are executed by transactions. If the oPrrder is the same then we know the schedule is equivalent to a serial schedule..
Precedence graphs can be used to show conflicting operations of transactions. What would the presence of a cycle in a precedence graph mean?
It would mean the schedule it represents is not serialisable.
Why is it important to make schedules of multiple concurrent transactions serialisable?
To keep the transaction ISOLATION property intact (ACID).
What is the aim of two-phase locking?
To ensure the effects of the transactions on shared data is serially equivalant.
How does two phase locking work?
A transaction is either in acquire phase or release phase. Once the transaction starts to release it cannot acquire any further locks.
What is the difference between strict 2PL and 2PL?
In the strict form all locks are released on commit.
In the non-strict form the locks are gradually released
What are the two classes of concurrency control mechanism?
Pessimistic algorithms assume there are likely to be conflicts and take measures to avoid them.
Optimistic algorithms assume conflicts will be rare, and can dealt with after the event.
Name two types of pessimistic algorithm
Two-phase locking and Time Stamp Ordering.
How does Time Stamp ordering work as an algorithm of concurrency control?
Each object has a time stamp associated with the transaction that accessed it most recently. If another transaction requests an operation that conflicts with one that has been carried out previously on this object the time stamp is compared. If the transaction’s time stamp is earlier than the one recorded by the object the transaction must abort and restart with a later timestamp.
Basically the time stamp cannot go backwards.
Name some advantages of Time Stamp Ordering.
it is efficient and has fewer deadlock problems than locking.
It is simple - few overheads.
Name some disadvantages of time-stamp ordering.
It can suffer from high levels of aborts.
May be more restrictive than 2PL.
What is the main goal of optimistic concurrency control?
To avoid the overheads of locking managment, deadlock prevention or detection.