ConcurrencyControl Flashcards

1
Q

What are the two types of locks in database systems?

A

Shared (S) lock for reading and Exclusive (X) lock for both reading and writing

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

What is a Shared (S) lock?

A

A lock that allows a transaction to read a data item but prohibits any updates

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

What is an Exclusive (X) lock?

A

A lock that allows a transaction to both read and write a data item preventing access by other transactions in either mode

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

What are the two phases in Two-Phase Locking (2PL)?

A

1) Growing Phase: acquire locks no releases 2) Shrinking Phase: release locks no acquisitions

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

What is Strict 2PL?

A

A variant of 2PL where transactions hold all exclusive locks until they commit or abort preventing others from reading uncommitted changes

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

What is Rigorous 2PL?

A

A variant of 2PL where transactions hold all locks (both shared and exclusive) until commit or abort

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

What causes a deadlock in database systems?

A

When a set of transactions form a cycle of dependencies each waiting for a resource held by another

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

What are the two main approaches to handle deadlocks?

A

1) Deadlock Detection using wait-for graphs 2) Deadlock Prevention using timestamp-based ordering

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

What information does a lock table contain?

A

Data Item Transaction ID Lock Mode and Queue of Requests

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

What is the Tree Protocol in graph-based protocols?

A

A protocol where data items are organized hierarchically first lock can be on any item subsequent locks must follow hierarchy and items can be unlocked anytime but not relocked

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

What information does Timestamp-Based Protocol maintain for each data item?

A

R-timestamp (largest timestamp of successful read) and W-timestamp (largest timestamp of successful write)

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

When is a read operation allowed in Timestamp-Ordering Protocol?

A

Only if the transaction’s timestamp is greater than or equal to the write timestamp of the data item

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

When is a write operation allowed in Timestamp-Ordering Protocol?

A

Only if the transaction’s timestamp is greater than both the read and write timestamps of the data item

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

What is MVCC (Multiversion Concurrency Control)?

A

A scheme that maintains multiple versions of each data item to improve concurrency and reduce conflicts

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

What are the main advantages of MVCC?

A

1) High concurrency as reads never block writes 2) Reduced likelihood of deadlocks

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

What are the main disadvantages of MVCC?

A

1) Increased storage and memory requirements 2) Complexity in conflict resolution

17
Q

How does the lock table handle lock requests?

A

Checks compatibility with existing locks grants if compatible adds to queue if not compatible removes all requests if transaction aborts

18
Q

What happens when a lock is released in the lock table?

A

System checks the queue to determine if pending requests can now be granted ensuring fairness by granting locks in order

19
Q

What is the main limitation of the Tree Protocol?

A

It can increase overhead by requiring transactions to lock additional data items that they do not access directly

20
Q

What is the key feature of snapshot reads in MVCC?

A

Transactions access the version of the data item that matches their timestamp ensuring reads are non-blocking