Concurrency Control Flashcards

(25 cards)

1
Q

Define concurrency control

A

is the process of managing simultaneous operations on the database without having them interfere with one another.

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

what are the objectives of concurrency control

A
  • schedule transactions to avoid interference
  • guarantee serialisability
  • Enforce ACID properties
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What is pessimistic concurrency control

A

assumes that conflict is likely and take steps to prevent it
- Locking, timestamping
- relational DB mostly use

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

What is optimistic concurrency control

A

assumes that conflict is unlikely and only checks for it when transaction commits

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

Define locking

A

when a transaction is accessing the database, a lock may deny access to other transactions to prevent incorrect results.

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

What must a read operation acquire

A
  • Shared/read lock
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What must a write/update operation acquire

A

an exclusive/write lock

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

What can locks be acquired to

A
  • The whole database
  • a file
  • a page/a block block
  • a record
  • A field value of a record
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What are the rules of locking

A

― A transaction must issue read_lock(X), or write_lock(X) before any read(X).
― A transaction must issue write_lock(X) before any write(X).
― A transaction must issue unlock(X) after read(X) or write(X).

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

Does shared/exclusive locks guarantee serialisability

A

NO, more strict protocols are required i.e two phase locking

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

What is two phase locking

A

Two-Phase Locking (2PL): All locking operations precede the first unlock operation in a transaction.

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

What is the drawing/expanding phase

A

uring which new locks on items can be acquired but none can be released;

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

What is the shrinking phase

A

during which existing locks can be released but no new locks can be acquired.

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

Define deadlock

A

A circular situation where each of two (or more) transactions are waiting to acquire locks that are held by the other.

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

What are the techniques for handling deadlock

A
  1. Timeouts
  2. Deadlock detection and recovery
  3. Deadlock prevention
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

What is a time out

A
  • A transaction will wait for a (database defined) period to acquire a lock.
  • If this time runs out then the whole transaction is rolled back and restarted.
17
Q

What is a wait for graph

A

a graph with a node for each transaction. There are directed edges from e.g. T1 to T2 if T1 is waiting to lock an item currently help by T2

18
Q

When does a deadlock exist in the wait lock graph

A

A deadlock exists if the graph contains a cycle.

19
Q

What does DBMS need to do once a deadlock is detected

A

DBMS needs to abort one or more of the transactions

20
Q

What is starvation in deadlock detection and recovery

A

Starvation:thesametransactionisalwayschosenasavictim,andthetransactioncannever complete.

21
Q

What are the issues to consider in recovery

A

― Which transaction to roll back?
* Abort transactions that incur the minimum costs.
― How far to roll a transaction back? * Totalrollbackorpartialrollback
― Avoid starvation

22
Q

What are the two types of deadlock prevention

A

Wait-die algorithm
― only older transactions can wait for younger ones
Wound-wait algorithm
― only younger transactions can wait for older ones

23
Q

Define time stamp

A

A unique identifier created by the DBMS that indicates the relative starting time of a transaction.
― Either a logical counter or the system clock.

24
Q

Define time stamping

A

a concurrency control protocol that orders transactions in such
a way that older transactions get priority in the event of conflict.

25
What are optimistic techniques
assume that conflict is rare. ― Before a transaction commits, a check is performed to determine whether conflict has occurred. ― If yes, roll back and restart