Concurrency Control Protocols Flashcards

1
Q

What is a Concurrency Control Protocol?

A

A protocol that defines the way in which the database manages concurrent transactions and handles conflicts.

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

What are the 2 techniques of concurrency control protocols? Define each…

A

Pessimistic : Assumes transaction conflicts will occur, therefore, implements pre-emptive procedures to prevent conflicts. These include locking and timestamping.
Optimistic : Assumes that transaction conflicts are unlikely to occur. Therefore, doesn’t check for conflicts until the time of commit. This is less computationally expensive than pessimistic.

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

What is mean by locking? Which conflict management type uses it?

A

Locking is when an aspect of the database is locked during a transaction. This prevents other transactions operating on the locked component.
Locking is used in pessimistic control.

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

What are the 2 types of locking? Define each…

A

Shared : This is used in read operations. The lock can be acquired simultaneously by multiple transactions. This is because read transactions don’t risk transaction conflict.
Exclusive : This is used in write transactions. This lock on the database can only be acquired by one transaction at a time. This means only one transaction can write at a time.

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

What is an issue with single locking?

A

It doesn’t enforce serialisability.

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

What is the solution to the single locking issue?

A

Implement 2 phase locking.

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

Define 2 phase locking… What are the 2 phases in it?

A
  • 2 phase locking implements serialisability into the transactions. This prevents conflicts. It does this by ensuring all locking operations are completed before the first unlock operation is completed.
  • Growing phase : The locking of all the database components in question.
  • Shrinking phase : The release of the locked items. No new locks can be acquired.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What issue can 2 phase locking cause?

A

Deadlock : When 2 or more transactions are waiting to acquire a lock that is held by the other.

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

What are the solutions to Deadlock caused by 2PL?

A

Timeout : Transactions are given a time limit to acquire the lock. Rollback occurs if the time limit is exceeded.
Issue with Timeout : The time may be exceeded even if the transaction is not waiting to acquire a lock, and a rollback may occur despite deadlock not being present.

Deadlock Detection and Recovery: A wait-for-graph is created a analysed for cycle. If a cycle is present, deadlock has occurred and a rollback can be conducted.

Deadlock Prevention : Each transaction is timestamped, and wait-die or wound-wait algorithms are executed if needed.

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

What are the wait-die and wound-wait algorithm?

A

Wait-die : Old transactions wait for younger transactions to complete first.
Wound-die : Young transactions wait for older transactions to complete first.

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

Define Timestamping…

A

Each transaction has its creation time noted, thus the age of the transaction can be monitored. This means that older transactions can take precedence over younger transactions in the case of conflicts. No locks are used.

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

Define what is meant by optimistic techniques…

A

Transactions are only checked for conflict just before the commit takes place. If a conflict is found, a rollback occurs.

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