Transactions Flashcards

1
Q

What does the A stand for in ACID?

A

Atomicity: Either all of the transaction should occur or none of it

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

What does the C stand for in ACID?

A

Consistency: The transaction should not leave the database in an inconsistent state

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

What does the I stand for in ACID?

A

Isolation: Transactions shouldn’t be aware of other transactions

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

What does the D stand for in ACID?

A

Durability: All changes made to the database should be persisted to storage.

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

What are the 5 transaction states?

A
  • Active
  • Partially committed
  • Committed
  • Failed
  • Aborted
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

When is the transaction in the Active state

A

The initial state and the state the transaction stays in while executing.

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

When is the transaction in the partially committed state?

A

After the final statement in the application logic has been executed.

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

When is the transaction in the committed state?

A

After successful completion of the transaction.

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

When is the transaction in the failed state?

A

After the discovery normal executing can no longer proceed.

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

When is the transaction in the aborted state?

A

After the roll back occurs and the database is back in its state prior to the start of the transaction. Two options after abort:
Restart transaction
Kill the transaction

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

What is a schedule?

A

Order in which instructions of transactions are executed. Must consist of all instructions for scheduled transactions and preserve their order.

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

What is a serial schedule?

A

Transactions are run serially to completion - ensure consistency.

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

What are non-serial schedules?

A

Used for concurrent execution, doesn’t always give consistent results.

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

Why do we need equivalent schedules?

A

Need to have non-serial schedules function like a serial scheduler in order to have consistent database.

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

When are two schedules conflict equivalent?

A

IF:

  1. One can be transformed into the other by a series of swaps of non-conflicting adjacent instructions.
  2. It is conflict equivalent to some serial schedule.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

How do we construct a directed precedence graph?

A

Add edge between any vertices that can’t be swapped for a data item (AKA anything that isn’t 2 reads).

17
Q

What does each edge in a directed precedence graph mean?

A

Ti-> Tj,

Ti must be executed before Tj in any serial schedule S’ == S

18
Q

What happens if a directed precedence graph has no cycles?

A

Schedule is conflict serialisable

19
Q

When there are cycles in a directed precedence graph, what does that mean?

A

The schedule is not conflict serialisable.

20
Q

What modes of locking are there?

A

Exclusive, lock-X. R/W

Shared, lock-S. R only

21
Q

What is a locking protocol?

A

Set of rules followed by all transactions while requesting and releasing locks. Restrict the set of possible schedulers. Deadlocks and starvation may occur.

22
Q

How are deadlocks and starvation related?

A

Deadlocks cause rollbacks of the lowest-valued transaction. If the same one is constantly rolled back then it is starved.

23
Q

How does the 2-phase locking protocol work?

A

Phase 1: Growing phase. Transaction may only obtain locks.

Phase 2: Shrinking phase. Transaction may only release locks.

24
Q

What are the advantages of having a 2 phase locking protocol?

A

Transaction execution schedulers are equivalent to serial schedulers in order of their lock points

25
Q

What is a lock point?

A

Point where transaction acquired its final lock.

26
Q

How do we construct wait for graphs?

A

When Ti is waiting for Tj to release a data item, then we draw an edge.

27
Q

How do we recover from deadlocks?

A

Roll back transaction to break deadlock.

28
Q

How does the wait-die scheme work?

A

Older transaction wait for younger to release data item, younger transaction never wait for old ones - roll back instead.

29
Q

How does the wound-wait scheme work?

A

Older transaction “wounds” (forces rollback of) younger transactions. Younger transactions may wait for older ones.

30
Q

How do timeout-based schemes work?

A

A transaction waits for a lock for a specified amount of time, after which it rolls back.

31
Q

How do Graph-based protocols work?

A

Impose partial ordering on the set. If di -> dj then acquiring a lock on dj is only allowed if a lock on the parent Di is obtained first.