Week 8 L1 Flashcards

1
Q

What do we mean by transactions

A

A transaction is a logical unit of work.
A transaction consists of the execution of an application-specified sequence of operations.
e.g., SELECY, INSERT, UPDATE, DELETE

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

What do we mean by commit/roll protocol?

A

atomicity is implemented by the commit/rollback protocol.
User must define boundaries of a transaction.
Begin : START TRANSACTION
Make permanent changes: COMMIT
Undo transaction : ROLLBACK

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

What are log files?

A

Keep track of database transactions.
Contain information about all changes to a database.
These support the commit/rollback protocol.

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

What do log files contain ?

A

Before-image of a data item, i.e., value before change
After-image of a data item. i.e., value after change
Lots of other information- e.g. timestamps etc

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

How do commits and rollback use log files

A

ROLLBACK uses before image values backwards.

Commit uses after image values forward.

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

What do we mean by concurrency control?

A

The process of managing simultaneous transactions without on interfering with one another.
Concurrency allows much more efficient use of resources, resulting in improved database performance.

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

What are the problems with concurrency?

A

Concurrent access can cause interference and result in data inconsistencies.
Lost update- more than one transaction trying to update the same data.
Uncommitted dependency
Inconsistent analysis

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

What do we mean by serialisation?

A

If transactions were only allowed to execute in series, then these concurrency problems would not exist.
The serialisation principle:
When two transactions operate in a parallel interleaved manner, then their effects should be the same as if they operated in a purely serial manner.

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

How do we guarantee serialisability?

A

We use the two-phase locking protocol.

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

What is a transaction lock

A

A transaction lock on data can prevent access to other transactions to prevent incorrect results.

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

transaction lock two types?

A

Shared read lock (S-lock)- shared reading but not writing.
Exclusive write lock(X-lock)- exclusive access
A transaction may have to wait for a lock to be released until placing its own lock on the data item.

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

What Do COMMIT AND ROLLBACK do to locks?

A

They release them.

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

What do we mean by Two phase locking (and what are they)?

A

All locking operations must precede the first unlock operation in the transaction.
There are two phases:
Growing phase- acquires all locks.
Shrinking phase – releases all locks but acquires none.

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

What does the lost update solution cause?

A

A deadlock

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

How to solve deadlock ?

A

This is when two or more transactions are in a simultaneous wait state, each waiting for locks held by the other to be released.
Breaking the deadlock involves the lock manager, choosing one of the transactions and rolling it back – these releases its locks and allows the other transaction to proceed
Some systems will then re-execute the rolled back transaction.

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

What do we mean by starvation? give example of a solution

A

When a transaction waits for an indefinite period of time while others continue normally
For example, when transaction wants X lock which it can never get because of new transactions continually gaining S-locks.
Solutions include locking in the order requested or increasing priority according to length of waiting time and number of previous aborts.

17
Q

What do we mean by recovery?

A

Restoring the database to a correct state in the event of failure
The transaction represents the basic unit of recovery.
Recovery must ensure atomicity by undoing uncommitted transactions and durability by redoing committed transactions after failure.
Recovery makes use of log files to restore the database.

18
Q

What do we mean by Checkpoint ? What are the operations

A

A synchronisation point between the database and log file . All buffers are forced-written to secondary storage.
This involves the following operations:
Write all log records to secondary storage
Write contents of buffers to secondary storage
Write a checkpoint record to the log file. This includes a list of all transactions in progress.

19
Q

What are the steps in the recovery technique?

A

Write ahead to the log file before the database as follows:
When transaction starts, register in log.
When the write operation performed, write data record to log.
Once the log record is written, write the update to the database buffers.
The updates to the database itself are written when the buffers are next flushed to secondary storage.
When the transaction commits, register in log.