Session 4 : Concurrency Control Flashcards

1
Q

Concurrency Control?

A

Managing multiple transactions in shared database systems
to prevent interference between operations from different users or applications.

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

Purpose of Concuttency control?

A
  • Prevent conflict between transaction
  • Maintain data consistency and integrity
  • Establish the correct order of concurrent transactions.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Problems due to concurrency?

A
  • Loss Updates : When two transactions update the same data, and one update is overwritten, causing data loss.
  • Uncommitted Data : When one transaction makes changes but is not committed, and another tansaction reads these uncommited data.
  • Inconsistent Retrieval : When a transaction reads data that is an inconsistent or intermediate state dute to the interleaving of other transactions.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

The Scheduler?

A

A special program within DBMS that determines the order in which operations from concurrent transactions are executed.

it is important bcoz,
the order of the operations becomes critical if the transactions access the same or related data, but it dosn’t matter if they access unrelated data.

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

The Scheduler ensures?

A
  • Serializanility and Isolation of transactions by managing the order of opearations.
  • Efficient use of CPU
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Problems with first-come, first-served?

A
  • Inefficient
  • Waste CPU time

Solution : Improve system efficiency by making better use of unused CPU time.

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

Concurrency control methods?

A
  1. Locking methods (Two-Phase Locking)
  2. Time Stamping
  3. Optimistic
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What is a Lock?

A

A mechanism used to control access to data items when multiple users need to access the same data concurrently.

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

Types of Locks?

A
  1. Binary Locks
    * Has two possible states, Locked(1) and Unlocked(0)
    * If Locked, data item is unavailable to other transactins, and if Unlocked it is available to accessed by any transaction.
  2. Shared (Read) Locks
    * Allow transaction to read, but not modify a data item.
    * Multiple transactions can hold shared locks on the same data at the same time, as long as no exclusive lock is held.
  3. Exclusive (Read & Write) Locks
    * Allows a transaction to read & write a data item, but prevent any other transaction from accessing the same data item - not even for reading.
    * Only one transaction can have an exclusive lock on a data item at any given time.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

Limitations of Binary Locks?

A
  • Too restrictive for optimal performance.
  • Concurrency issues : even when transactions only read data, binary locks may unnecessarily block access to the same data.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

Lock compatibility matrix?

A
  • S + S : True (allowed)
  • S + X : False (not allowed)
  • X + X : False (not allowed)
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

Lock Manger?

A

A crucial component in DBMS,
responsible for controlling lock information by assigns, monitors and enforces rules for the locks.

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

Rules enforced by the Lock Manager?

A
  1. Lock Request : must Lock the item first
  2. Lock Granting : if not already locked, the lock will be granted.
  3. Lock Compatibility Check : if locked, check compatibility, then granted/wait
  4. Lock Holding & Release : hold a lock, until it is explicitly released.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

Exclusive locks releasing….

A

must be released before the effects of any write operation become visible to other transactions.

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

Lock Granuarlity?

A

The level of detail or size of the data that a lock protects.

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

Two-Phase Locking (2PL)?

A
  • Mange how transactions get and release locks.
  • Ensures the same results as if the transactions were run sequently.
17
Q

Key rules of 2PL?

A
  1. No conflicting Locks
  2. Unlockin happens last
  3. Locked point
18
Q

2 phases of 2PL?

A
  1. Growing phase : transaction gets all the locks it needs.
  2. Shrinking phase : Once done, transaction release all the locks.
19
Q

Problems of 2PL?

A
  1. High transaction processing cost
  2. Deadlocks
20
Q

Deadlocks?

A

When two or more transactions wait for each other to release resources, and none of them can move forward, leaving them stuck.

Only occur when one transaction is trying to acquire an exclusive lock on a data item

21
Q

Deadlock control techniques?

A
  1. Deadlock prevention : aborting transactions and reschedule (rolled back) before they can lead to a deadlock.
    (High deadlock risk)
  2. Deadlock detection : DBMS checks for deadlocks, if detected, one transaction is aborted and restart.
    (Low deadlock risk)
  3. Deadlock avoidance : Prevents dead locks by managing the sequence of lock acquisition.
    (Low system time priority)
22
Q

What is time stamps?

A

Assigning a unique value to each transaction when it starts.

23
Q

Properties of timestamps?

A
  • Uniqueness
  • Monotonicity
24
Q

Disadvantages of timestamps methods?

A
  • Additional storage requirements
  • Increased memory and Processing Overhead
  • High resource consumption