ch18-updated-2019-03-08 Flashcards

(75 cards)

1
Q

What is a lock in concurrency control?

A

A mechanism to control concurrent access to a data item

Locks can be in exclusive (X) mode or shared (S) mode.

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

What are the two modes of locking data items?

A
  • Exclusive (X) mode
  • Shared (S) mode
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What does an exclusive (X) lock allow?

A

Both reading and writing of a data item

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

What does a shared (S) lock allow?

A

Only reading of a data item

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

What must a transaction do after requesting a lock?

A

Proceed only after the lock request is granted

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

What is a locking protocol?

A

A set of rules followed by all transactions while requesting and releasing locks

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

What is deadlock in concurrency control?

A

A situation where two or more transactions are waiting for each other to release locks

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

What is one method to handle deadlock?

A

Roll back one of the transactions involved in the deadlock

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

What is the Two-Phase Locking Protocol?

A

A protocol that ensures conflict-serializable schedules with two phases: Growing and Shrinking

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

What occurs during the Growing Phase of Two-Phase Locking?

A

Transactions may obtain locks but not release them

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

What occurs during the Shrinking Phase of Two-Phase Locking?

A

Transactions may release locks but not obtain new ones

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

What does strict two-phase locking ensure?

A

A transaction must hold all its exclusive locks until it commits or aborts

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

What is rigorous two-phase locking?

A

A transaction must hold all locks until it commits or aborts, allowing serialization based on commit order

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

True or False: Two-phase locking is a necessary condition for serializability.

A

False

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

What is the purpose of a lock manager?

A

To manage lock and unlock requests from transactions

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

What is a wait-for graph?

A

A directed graph that represents transactions waiting for locks held by other transactions

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

What indicates that the system is deadlocked when analyzing a wait-for graph?

A

The presence of a cycle

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

What is the purpose of deadlock detection?

A

To identify cycles in the wait-for graph and resolve deadlocks

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

What is the difference between total rollback and partial rollback?

A
  • Total rollback: Abort and restart the transaction
  • Partial rollback: Roll back only as far as necessary to release locks
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
20
Q

What is multiple granularity in concurrency control?

A

A technique allowing data items to be of various sizes with a hierarchy of data granularities

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

What are intention lock modes?

A
  • Intention-shared (IS)
  • Intention-exclusive (IX)
  • Shared and intention-exclusive (SIX)
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
22
Q

What is the tree protocol in locking?

A

A graph-based locking protocol that allows only exclusive locks and follows a parent-child locking relationship

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

What is the phantom phenomenon?

A

Occurs when a transaction reads a set of data and another transaction inserts data that affects the result of the read

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

Fill in the blank: A transaction that inserts a new tuple into the database is automatically given an ______ lock on the tuple.

A

X-mode

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
25
What is starvation in concurrency control?
A situation where a transaction is perpetually denied access to the resources it needs
26
What is the wait-die scheme in deadlock prevention?
An older transaction may wait for a younger one, while younger transactions are rolled back if they wait for older ones
27
What is the wound-wait scheme in deadlock prevention?
An older transaction forces a rollback of a younger transaction instead of waiting for it
28
What is a transaction T2 that inserts a tuple while T1 is active?
A transaction that inserts a tuple can conflict with T1 even if they do not access any tuples in common. ## Footnote This is conceptually a conflict due to the interactions in the database state.
29
What can result from using only tuple locks?
Non-serializable schedules can result. ## Footnote For example, a scan transaction may not see a new instructor inserted by an update transaction.
30
What is a scenario where conflicts can occur with maximum instructor IDs?
Both T1 and T2 finding the maximum instructor ID in parallel and creating new instructors with ID = maximum ID + 1. ## Footnote This results in both instructors receiving the same ID, which is not possible in a serializable schedule.
31
What is the conflict at the data level when handling phantoms?
A transaction performing a predicate read conflicts with another transaction inserting, deleting, or updating a tuple that affects the same information. ## Footnote This conflict should be detected, typically by locking the relevant information.
32
What is a solution to handle phantoms?
Associate a data item with the relation to represent what tuples it contains. ## Footnote Transactions scanning the relation acquire shared locks, while those modifying tuples acquire exclusive locks.
33
What does the index locking protocol do?
Prevents phantoms by requiring transactions to lock all index leaf nodes they access in shared mode. ## Footnote Exclusive locks on index leaf nodes are required for insertions, updates, or deletions.
34
What is the next-key locking protocol?
Locks all values that satisfy index lookup and also the next key value in the index. ## Footnote This protocol provides higher concurrency compared to index locking.
35
What is the purpose of timestamp-based concurrency control?
Manages concurrent execution such that the timestamp order equals the serializability order. ## Footnote Each transaction is issued a unique timestamp upon entering the system.
36
What does the timestamp-ordering protocol maintain for each data item Q?
W-timestamp(Q) and R-timestamp(Q). ## Footnote W-timestamp is the largest timestamp of any successful write, while R-timestamp is for successful reads.
37
What happens if TS(Ti) < W-timestamp(Q)?
The read operation is rejected, and transaction Ti is rolled back. ## Footnote This is to prevent reading an overwritten value.
38
What is Thomas’ Write Rule?
A modified version of the timestamp-ordering protocol that allows obsolete write operations to be ignored under certain circumstances. ## Footnote This allows for greater concurrency.
39
What are the three phases of a validation-based protocol?
1. Read and execution phase 2. Validation phase 3. Write phase ## Footnote Each transaction must go through these phases in order.
40
What does multiversion concurrency control aim to do?
Keeps old versions of data items to increase concurrency. ## Footnote It includes variants like multiversion timestamp ordering and snapshot isolation.
41
What happens during a read operation in multiversion schemes?
An appropriate version of the data item is selected based on the transaction's timestamp and returned immediately. ## Footnote Reads never have to wait.
42
What is the main benefit of using snapshot isolation?
Allows read-only transactions to operate without conflicts from OLTP transactions. ## Footnote This improves performance for decision support queries.
43
True or False: The timestamp-ordering protocol guarantees cascade freedom.
False. ## Footnote The schedule may not be cascade-free and may not even be recoverable.
44
Fill in the blank: The validation test for transaction Tj succeeds if for all Ti with TS(Ti) < TS(Tj), either finishTS(Ti) < startTS(Tj) or _______.
startTS(Tj) < finishTS(Ti) < validationTS(Tj) and the set of data items written by Ti does not intersect with the set of data items read by Tj.
45
What is a key characteristic of multiversion timestamp ordering?
Reads always succeed. ## Footnote A write by Ti is rejected if it conflicts with another transaction that has already read an older version.
46
What happens if Q has two versions Q5 and Q9, and the oldest active transaction has a timestamp > 9?
Q5 will never be required again
47
What is the motivation behind Snapshot Isolation?
Decision support queries that read large amounts of data have concurrency conflicts with OLTP transactions that update a few rows
48
What is the first solution proposed for Snapshot Isolation?
Use multiversion 2-phase locking
49
How does the multiversion 2-phase locking solution work?
Gives logical snapshot of database state to read-only transactions
50
What is a potential problem with using a snapshot of the database state for every transaction?
Variety of anomalies such as lost updates can result
51
What is the basic mechanism of Snapshot Isolation?
A transaction takes a snapshot of committed data at start and always reads/modifies data in its own snapshot
52
What is the 'first-committer-wins' rule in Snapshot Isolation?
Commits only if no other concurrent transaction has already written data that it intends to write
53
What are the benefits of Snapshot Isolation?
* Reads are never blocked * Performance similar to Read Committed * Avoids several anomalies
54
What anomalies does Snapshot Isolation avoid?
* No dirty reads * No lost updates * No non-repeatable reads
55
What is a problem with Snapshot Isolation?
It does not always give serializable executions
56
What does serializable mean in the context of transactions?
Among two concurrent transactions, one sees the effects of the other
57
What is the 'skew write' phenomenon in Snapshot Isolation?
Occurs when two transactions start at the same time and create the same order number
58
What is Serializable Snapshot Isolation (SSI)?
An extension of snapshot isolation that ensures serializability
59
How does SSI ensure serializability?
Tracks read-write dependencies separately and rolls back transactions where cycles can occur
60
Which database implements Serializable Snapshot Isolation from version 9.1 onwards?
PostgreSQL
61
What can cause anomalies in Snapshot Isolation?
Concurrent updates that modify different items based on a previous state of the item modified by another transaction
62
What is the 'first-updater-wins' variant in Snapshot Isolation?
Checks for concurrent updates when a write occurs by locking the item
63
What is the main drawback of the 'first-updater-wins' approach?
The lock must be held till all concurrent transactions have finished
64
What is the 'select .. for update' clause used for?
To ensure serializability by treating all data read by the query as if it were also updated
65
What is degree-two consistency?
Differs from two-phase locking in that S-locks may be released at any time, but X-locks must be held till the end of the transaction
66
What is cursor stability in SQL?
Each tuple is locked, read, and the lock is immediately released
67
What is the default consistency level in most database systems?
Read committed
68
What is optimistic concurrency control?
A method that avoids locking and is effective in real-time settings
69
What is the crabbing protocol in B+ tree locking?
Locks the root node in shared mode and releases locks on nodes after locking all required children
70
What is the main advantage of using main-memory databases for concurrency control?
Short term lock can be obtained on the entire index for the duration of an operation
71
What is the ABA problem in concurrency control?
Occurs when a node is deleted and then reinserted, causing a concurrent operation to reference an outdated state
72
What is view equivalence in scheduling?
Schedules are view equivalent if certain read/write conditions are met for each data item
73
What is a view serializable schedule?
A schedule that is view equivalent to a serial schedule
74
What is the complexity of checking if a schedule is view serializable?
NP-complete
75
Is every conflict serializable schedule also view serializable?
Yes