Lecture 21 + 22 Flashcards

1
Q

What is a transaction? How is this done?

A

A sequence of operations on a database, which must either be completely executed or not executed at all.
If no errors occur then the changes are commited(made permanent), otherwise the changes are rolledback.

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

What are the ACID properties of transactions?

A

Atomicity(either all operations in transaction performed or none, a logical unit of work).
Consistency(A transaction transforms a consistent state of database into another, needs concurrency control to prevent interleaving).
Isolation(Transactions isolated from one another, not visible until commited or rolled back, concurrency controls).
Durability(Once user is notified transaction is completed, updates must be persistent despite failures, meaning committed changes are not reversed, needs failure recovery).
A and D relate to Failures, while C and I relate to concurrency controls.

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

What are the 3 concurrency problems, and what do we assume?

A

The lost update problem, the temporary update problem, and the incorrect summary problem. We assume it is possible to interleave operations and that the same database item is being accessed.

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

What is the lost update problem?

A

When an update is overwritten, because the original value was read in by another function before it was written.

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

What is the temporary update problem?

A

Occurs when a transaction fails and rollsback changes, but a second transaction read the value before it was rolled back.

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

What is the Incorrect summary problem?

A

When some things are read before the transaction finishes, leading to it being inconsistent with later values.

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

What is a schedule of transactions? What is the notation?

A

An ordering of the operations of the transactions, operations of each transaction must be in the same order that they appeared in the transactions.
Notation is r for read, w for write, c for commit, and a for abort, with a number after to specify which transaction and a (x) to specify the item accessed.

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

What is a conflict within a schedule?

A

Occures when two operations in a schedule: belong to different transactions, access the same item, and at least one is a write.

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

What is a serial schedule? What about a nonserial? What is serialisability?

A

A schedule is serial if for every transaction, all its operations are executed consecutively, if the transactions are independent every serial schedule is correct.
A nonserial has interleaving, not all are correct.
A schedule is serialisable if it is equivalent to some serial schedule of the same transactions.

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

What is locking?

A

A transaction acquires a lock on an object, this can be a write lock(exclusive) or read lock(Shared).
We issue a read or write lock before reading the item, a write lock before write item, and an unlock after all read items and write items are completed.
If a write lock is held then a request for either lock will be denied, if a read lock is held then read locks can be granted, but not write locks.
If denied a lock goes into a wait state until the lock is released, the system must guarantee the transaction does not wait forever, possibly with a queue.

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

What is two phase locking?

A

Before operating on any object, must acquire a lock, after releasing a lock must never acquire more locks. This has two phases, the expanding phase, where it is gaining locks and the shrinking phase, when it is losing them.
If all transactions obey this then all possible interleaved schedules are serialisable.
This can be conservative(all items locked before transaction begins) or strict(no write locks released until commit or rollback).

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

What is timestamp based deadlock prevention? What are the two protocols that use this?

A

Transactions ordered based on start of transaction. In Wait-die if the transaction requesting the lock is older it waits, else it dies and is restarted with the same timestamp. In wound wait if the transaction is older it wounds the holding transaction, stopping it, and restarting after a random time. Otherwise it is younger, and waits.

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

What are some non time-based deadlock prevention schemes?

A

No waiting: If a transaction cannot acquire a lock, it is aborted and restarted after a time delay without checking whether a deadlock would occur.
Cautious waiting: if a transaction tries too acquire a lock from a non blocked transaction it waits, otherwise it is aborted.
Timeouts: if a transaction waits longer than a set time deadlock is assumed and the transaction is aborted.

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

How can we detect deadlocks?

A

Construct a wait for graph, a node for each transaction, a directed edge whenever one is waiting on an item locked by another, deadlock is indicated by a cycle.

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