Week 3 - Lock-Based Concurrency Control Flashcards

1
Q

What is the most the most widely used protocol Lock-Based Concurrency Control

A

Strict Two-phase Locking, or Strict 2PL

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

What is a lock-based concurrency control?

A

he lock-based concurrency control,
the basic idea is to use locks to lock data items, that we kind of suspecting if there is a conflict that might lead to inconsistency
if these data items are read or written

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

What happen in a Strict 2PL

A

1) If T wants to read an object, first obtains an S lock.
2) If T wants to modify an object, first obtains X lock.
3) Hold all locks until end of transaction.

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

What are the advantages of Strict 2PL

A

Guarantees serializability, and avoids cascading aborts, too!

also avoids WW problems!

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

3Items of Strict 2PL

A

1) Each transaction must obtain a Shared lock on object before reading, and an exclusive lock on object before writing.
2) All locks held by transaction are released when the transaction completes
3) Only allows serializable schedules

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

What controls all the locking

A

Lock manager -

Keeps track of what kind of lock this item

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

What does a lock manager do?

A

1) Handled lock and unlock requests
2) Locking and unlocking have to be attomic operations
3) Lock upgrade

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

What does a Lock upgrade do?

A

Transactions that holds a shared lock can be upgraded to hold an exclusive lock

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

Strict two-phase locking gets is name from:

1) The two phases, lock acquisition and lock release
2) The two types of locks used
3) The two phases, locking/unlocking and cleanup
4) The two phases, lock acquisition and data write

A

1) The two phases, lock acquisition and lock release

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

What is a deadlock

A

Cycle of transactions waiting for locks to be released by each other.

A deadlock means that
one transaction wants to acquire a lock on a data item, and this data item is already
locked by another transaction.

On the other hand, this other transaction also want to acquire a lock on a data item
that is already also locked by the other transaction.

They’re both waiting on each other,

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

Two ways to avoid Deadlocks

A

1) here are deadlock prevention algorithms. So you add extra logic
into your concurrency control so that
you account for deadlocks. - Overhead

2) let the deadlock happen and take steps to actually break that deadlock.

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

One way to detect Deadlocks

A

Waits-for graph

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

What is a Waits-for graph

A

A waits-for graph is you
have the nodes in the graph or the transactions, and there is an edge between two transactions.
If one transaction is waiting for the other transaction to release a lock.

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

What kind of lock must a transaction acquire in order to read from a database?

1) Concurrency lock
2) Read lock
3) Shared lock
4) Exclusive lock

A

3) Shared lock

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

What kind of lock must a transaction acquire in order to write to a database?

1) Write lock
2) Atomicity lock
3) Exclusive lock
4) Shared lock

A

3) Exclusive lock

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

4 types of Database Failures

A

1) Transaction Failures
2) System Failures (hardware)
3) Media failures (hard-drive)
4) Communication failures (network)

17
Q

4 types of Database Failures

A

1) Transaction Failures - (abort transaction)
2) System Failures - (hardware)
3) Media failures - (hard-drive)
4) Communication failures - (network)

18
Q

When do databases enter a recovery state?

1) When there is a failure during a transaction.
2) When there is a failure of any kind.
3) When there is a failure due to loss of power.
4) When deleted data needs to be restored.

A

2) When there is a failure of any kind.

19
Q

2 Places that database info is stored

A

1) Hard drive

2) Database Buffer Manager (main memory buffer)

20
Q

Recovery Manager uses what

A

Log file, just appends (old value,and new value)

21
Q

5 Items that are in the log (write-ahead log)

A

1) Transaction identifier
2) Type of operation (action)
3) items accessed by the transaction to perform the action
4) Before image (old value)
5) After image (new value)

22
Q

Recovery - Redo

A

Performing actions from the log that might have been done, but not sure (committed)

23
Q

Recovery - Undo

A

Not committed before the crash, undo those.