14 Concurrency Control Techniques Flashcards

(22 cards)

1
Q

What is a lock in a database?

A

A label placed on data (X) to show it’s in use, written as Lock(X).

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

What is the role of the lock manager?

A

Tracks all locks, controls locking/unlocking, ensures safety and consistency.

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

What are the two states in binary locking?

A
  • Locked (1): item is in use
  • Unlocked (0): item is free
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What happens if a transaction tries to access a locked item?

A

It must wait in a queue until the lock is released.

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

What is a shared lock (read-lock)?

A

Allows multiple transactions to read X, but no one can write X.

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

What is an exclusive lock (write-lock)?

A

Only one transaction can read/write X, others must wait.

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

What are the system rules for multiple-mode locks?

A
  • Lock before read/write
  • Unlock after done
  • No double locking
  • Only unlock if you hold the lock
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What is a deadlock?

A

When two transactions wait on each other’s locks, causing a freeze.

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

Can locking alone guarantee serializability?

A

No, not always.

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

What is Basic 2-Phase Locking (2PL)?

A
  • Growing phase: acquire locks only
  • Shrinking phase: release locks only
  • Guarantees serializability, but not deadlocks
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

What is a lock upgrade and downgrade?

A
  • Upgrade: shared → exclusive
  • Downgrade: exclusive → shared
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

What is Conservative (Static) 2PL?

A

Locks all items at the start; avoids deadlocks and cascading rollbacks.

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

What is Strict 2PL?

A

Holds all locks until commit/abort; prevents cascading rollbacks but not deadlocks.

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

What is serializability in concurrency control?

A

Ensures final DB state is same as if transactions ran one after another.

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

What is cascade rollback prevention?

A

Stops one failure from causing others to roll back due to uncommitted data.

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

What are the three deadlock control techniques?

A
  • Avoidance (pre-check)
  • Detection (periodic check)
  • Prevention (lock all items at start)
17
Q

What is a livelock?

A

A transaction is stuck retrying without progressing while others run.

18
Q

How to fix livelock?

A

Use fair policies like first-come-first-serve or increasing priority with wait time.

19
Q

What is granularity of data items?

A

The size of data items (row, field, block, file, DB) a transaction interacts with.

20
Q

What is the tradeoff between small and large granularity?

A
  • Small = more concurrency, more overhead
  • Large = less concurrency, less overhead
21
Q

When is small granularity better?

A

When transactions use few, isolated records.

22
Q

When is large granularity better?

A

When many records from the same area are accessed.