Unit 6 Flashcards
SAQ 1 - A
Compare the concept of a transaction with that of a coarse-grained atomic action. What are their differences and similarities?
A transaction and a coarse-grained atomic action both consist of several operations, but these are treated as belonging together, and hence both are atomic. They both give the appearance of indivisibility. The difference is that a transaction also has the property of failure atomicity:
- if there is a failure part-way through the execution of the transaction, all the partly done operations are undone, so that it is as if nothing has happened;
- if the transaction completes, the results of the transaction are made durable (stored in persistent storage).
SAQ 1 - B
What are the desirable properties for transactions?
There are four desirable (ACID) properties: atomicity, consistency, isolation and durability.
SAQ 1 - C
What are the transaction states in the transaction state model?
The transaction model specifies the following transaction states: Active, Failed, Partially Committed, Committed and Aborted.
SAQ 1 - D
When a transaction is in the Partially Committed state, it has not fully completed. What are the possible next states? Describe the circumstances under which it would progress to each of them.
When a transaction is Partially Committed it can progress to the Committed state in the case where all the data involved in the transaction is written to disk and made durable. On the other hand, if there is a problem in making the data durable, the transaction is said to have Failed. The effects of the transaction are then undone, i.e. rolled back, and only then is the transaction completely finished when it enters the Aborted state.
SAQ 1 - E
What is the role of a TP system? List its components.
The task of the TP system is to manage the correct and efficient execution of transactions.
Transaction Manager, scheduler, recovery manager and a cache manager.
Exercise 2
What is the similarity between the definition of serialisability for transactions, and the definition of thread safety for classes as discussed in Units 3 and 4?
A class is considered thread-safe if its instances behave under concurrent method calls as if they were called sequentially. This concept is similar to that for the execution of transactions, which should behave as if their execution was serial.
SAQ 2 - A
What is a serial schedule?
A serial schedule is one in which transactions execute strictly one after the other, without any interleaving of operations.
SAQ 2 - B
Give the definition of serialisability.
A schedule for a group of transactions is serialisable if, and only if, it produces the same results as if the transactions had executed in some serial order.
SAQ 2 - C
When executing a number of transactions, several serial schedules may be possible. These serial schedules do not necessarily all give the same final results for the data objects involved. Explain whether or not you think this is problematic.
This is not problematic, as the main concern is whether the data objects are in a consistent state.
SAQ 2 - D
What are conflicting operations?
Operations conflict if the order in which they are performed affects the result.
SAQ 2 - E
How is the notion of conflicting operations used to determine whether a schedule is serialisable?
The notion of conflicting operation allows us to determine in what order transactions execute a pair of conflicting operations. Then, if for all the pairs of conflicting operations in a schedule the order of execution by transactions is the same, we know that the schedule is equivalent to a serial schedule.
SAQ 2 - F
Precedence graphs can be used as a notation for transactions and the conflicting operations of those transactions. Explain under which circumstances such graphs could contain a cycle.
A precedence graph contains a cycle if the schedule it represents is not serialisable.
SAQ 3 - A
What are the two phases of two-phase locking?
The two phases are acquire and release. In the acquire phase, the transaction gradually gets hold of all the locks it needs, as and when it needs them, but does not release any locks. In release, the transaction acquires no more locks but lets go of the ones it holds when it has completed work on the locked objects.
SAQ 3 - B
What is a shared lock and why might we want to use shared locks?
A shared lock is useful when non-conflicting operations are using the same object, and it is therefore safe for both to use the object. If a shared lock can be used, it increases concurrency
SAQ 3 - C
What is a simple alternative to deadlock detection?
Timeouts