TM - Locking Flashcards

1
Q

Locking

A

Mechanisms for central repository concurrency control.

Locks are variables linked with instances and holds state of instances acceptable access operations.

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

Binary Locks

A

Can be locked or unlocked (1 or 0). Ideal for mutual exclusion. Indivisible operations.

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

For transaction model, a Binary lock is invoked when:

A

Lock before R/W. Unlock after complete. No issue of Lock(x) if it already holds Lock. Same with unlock.

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

Problem with Binary locks

A

Their Totality

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

Multiple Mode Locks (Shared (R) or Exclusive (W) )

A

Lock can be in three states: Read, Write or Unlock.

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

For transaction Model, a Multiple Mode lock is invoked when:

A

Issues R/W lock before r(X), Issues W lock before W(x). Issus unlock after all operations conclude, only if it holds R/W lock. Doesn’t issue locks if x already has a lock.

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

Problem with Multiple Mode Locking

A

Use of locks alone does not guarantee serializability of transaction schedules. Stricter rules needed such as Two Phase Locking.

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

Two Phase Locking

A

2PL Scheduler manages locks by controlling when to lock or unlock a transaction.

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

If 2PL Theorem Holds:

A

No need to test for serializability of schedules.
Protocol enforces serializability.
Limits level of concurrency in a schedule.

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

Important 2PL Theorem

A

If all transactions in a scheduler adhere to a 2PL protocol then the schedule is serializable.

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

2PL protocol phases:

A

Lock Hoarding (Growing) phase [No locks released]
Releasing of Locks (Shrinking) phase [No locks required]

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

Types of 2PLs

A

Conservative (Static)
Strict

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

Conservative/Static 2PL

A

Hoards locks at start. If lock cannot be accessed it waits. Deadlock free. Difficult to use due to predeclaring R/Ws.

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

Sharing Phenomena

A

SQL Standard tries to explain sharing protocol through phenomena. Running concurrent transactions at different levels of isolation allows application designers to trade throughput for correctness. Lower isolation levels increase transaction concurrency but risk assessing object’s state that have not yet been committed

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

Strict 2PL

A

Releases all transaction locks after commit.
Not Deadlock free.
Guarantees Strict Schedule.
Recoverable Schedules and avoids cascading rollbacks.

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

Scheduler needs a strategy for avoiding deadlocks:

A

This can be done simply by use of a time out span, after time limit exceeded, abort transaction.

9
Q

ANSI/ISO SQL Specs. 4 Isolation Levels:

A

Serializable (Most strict)
Repeatable Read
Read Committed
Read uncommitted (Least Strict)

9
Q

Common Criteria to know which transaction to kill in deadlock

A

Amount of effort already invested, Cost of abortion, Amount of effort to finish executing transaction, Number of cycles that contain transaction.

10
Q

Granularity of Locks

A

Concurrency control mechanism that works on database items. A RDBMS can include:

Relation tuple, tuple attribute, disk block, file structure, complete database.

10
Q

Design Considerations for locks;

A

Larger the size, lower the concurrency level. Smaller the size, larger number of locks that have to be maintained.

11
Q

Phantom Phenomenon

A

Any transaction processing related command needs to be translated to basic and explicit R/W on DB objects.

Object may be a tuple, attribute or even physical ex. disk.