Transactions Flashcards

1
Q

What are transactions

A

These are used for controlling operations on persistent shared information.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Transaction properties and definitions

A

Atomicity
Consistency
Independence
Durability

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Atomicity

A

All or nothing. This state ensures automatic recovery of a system to its prior state in the event of failure

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Consistency

A

Serialisability. This ensures transactions are scheduled to run without interference

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Independence

A

Containment. This ensures all updates done by a transaction are visible to all to other transactions before it terminates

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Durability

A

Persistence. All results produced by a successfully completed terminated transactions are not affected by subsequent failures

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Transaction primatives

A

Begin transaction
End transaction
Abort

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

Begin transaction

A

Command indicating the start of a transaction

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

End transaction

A

This can have 2 outcomes

Normal termination: Normal ending where all changes made are saved and stored to disk
Abnormal termination: No results produced from transaction termination. This means failures occurred

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

Abort

A

Explicitly aborting transaction under control of program

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

Read lock

A

reading can be shared. A read lock is permitted provided object is not write locked

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

Write lock

A

Writing is exclusive so a write lock is permitted if there is no read or write lock on the object

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

Deadlocks

A

If a transactions response to a conflict is to wait for the lock, then there is a danger for deadlocking as it can lead to wait for cycles

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

2 Phase locking rules

A

(i) A transaction must obtain a lock on an object before using it;
(ii) growing phase: locks are acquired and acquired locks are not released;
(iii) shrinking phase: acquired locks are released and no new locks are acquired.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

Lock point

A

A transaction at some point in time must hold all the locks on objects
it is using in its computation. This point is called the lock point

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

Dirty read and cascade abort

A

(i) Transaction T1 updates object O1 and then releases its write lock, later T1 is aborted, and in the mean time, a transaction T2 puts a read lock on O1
(ii) T2 is reading dirty data as modifications of O1 made by T1 are cancelled when T1 aborts
(iii) This means T2 will have to abort, leading to cascade aborts.

17
Q

Strict 2 phase locking

A

The shrinking phase is made logically instantaneous as all locks are released together. This ensures independence property as a transaction can abort without causing cascade aborts.

18
Q

Simple deadlock prevention

A

Transaction never waits. If the transaction requesting a lock cannot obtain the lock (due to conflict), then the requesting transaction aborts

19
Q

Careful deadlock prevention

A

To permit waiting only if there is no danger of a deadlock. Transactions are assigned numbers (timestamps) using logical or physical clocks, such that transactions numbers are totally ordered

20
Q

Wait Die scheme

A

This is where an older transaction waits for a lock held by the younger one, and a younger transaction aborts if it wants a lock currently held by an older transaction.

Let Tr denote the transaction requesting a lock and Th denote the holder of the
lock, with whom the conflict occurs

if timestamp of Tr< timestamp of Th then Tr is old and waits else Tr is young and aborts

21
Q

Wound wait scheme

A

This is where only young waits for old, if an old transaction succeeds forcing its way to completion

Let Tr denote the transaction requesting a lock and Th denote the holder of the
lock, with whom the conflict occurs

if timestamp of Tr< timestamp of Th then Tr is old and waits else Tr is young and aborts

22
Q

2 Phase commit requirements

A
  • The termination of the transaction is carried out under the control
    of the client . The first phase is used by the coordinator to determine the outcome for the transaction, the second phase is used to enforce the decision taken by the coordinator

-Every node maintains a file called the ‘transaction log’ or ‘intentions list’ on stable store. The log maintains information about the transactions that node is taking part.

  • Every node has a recovery manager process that is executed during crash recovery of the node. The recovery manager scans the transaction log and tries to terminate the transactions that were interrupted by the crash.
23
Q

2PC algorithm

A

Client:
Phase1
send ‘get ready’ to all servers;
wait on timeout;
IF all reply ‘yes’ THEN {verdict := commit;
write verdict, transaction identifier, server
node addresses on the transaction log}
ELSE verdict := abort

Phase 2
Send verdict to all servers

Server
Phase 1
Wait on timeout for ‘get ready’ command;
IF none coming THEN abort;
IF command received and server wants to commit
THEN {copy new version of objects on the stable
store; write transaction identifier, coordinator
node address on the transaction log; send ‘yes’
to the coordinator} ELSE {send ‘no’; abort}

Phase 2
wait for the ‘verdict’; carry out the command;
IF no verdict coming THEN keep on checking
with the recovery manager of the coordinator
for the decision.