Concurrency control Flashcards

1
Q

What is a transaction?

A

A set of several operations constituting a logical task unit, converting a consistent state of the database to another consistent state.

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

What are the ACID properties of a transaction?

A
  • Atomicity
  • Consistency
  • Isolation
  • Durability
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Define Atomicity in the context of transactions.

A

All data should be successfully entered or failed in one transaction.

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

Define Consistency in the context of transactions.

A

The transaction result should always be the same expected value.

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

Define Isolation in transaction properties.

A

Another transaction should not intervene until commit or rollback is issued.

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

Define Durability in the context of transactions.

A

The persistence of a successful transaction should be guaranteed.

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

What is a transaction commit operation?

A

An operation that completes a transaction after permanently reflecting the results of all SQL statements in the database.

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

What is a transaction rollback operation?

A

An operation that restores all data values modified by a transaction to the state prior to execution when the transaction cannot continue.

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

What is the implementation of transaction concurrency?

A

Simultaneous execution of transactions to increase throughput and reduce latency.

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

What is a serializable schedule?

A

A schedule where transactions executed simultaneously yield the same result as sequential execution.

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

Define concurrency control.

A

A function that enables the successful execution of several transactions simultaneously in a database system.

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

What are the purposes of concurrency control?

A
  • Create serializable schedules
  • Guarantee maximum sharing
  • Ensure data integrity and consistency
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

What is a lost update?

A

Occurs when transactions update the same data simultaneously, leading to overwriting of updates.

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

What is a dirty read?

A

Occurs when other transactions refer to the intermediate execution result of a transaction.

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

What is inconsistency in databases?

A

A database remains inconsistent when two transactions are executed simultaneously.

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

What is a cascading rollback?

A

Occurs when a specific transaction cancels processing, affecting other transactions sharing data.

17
Q

What is an unrepeatable read?

A

When a transaction executes the same query twice, resulting in different outcomes due to modifications by other transactions.

18
Q

Name four concurrency control techniques.

A
  • Lock-based technique
  • Timestamp-based technique
  • Multi-version technique
  • Verification (optimistic) based technique
19
Q

What is the lock-based technique?

A

A mechanism where a transaction cannot read or write data until it acquires an appropriate lock.

20
Q

What is the timestamp-based technique?

A

An algorithm using system time or logical counter as a timestamp to serialize concurrent transactions.

21
Q

What is multiversion concurrency control (MVCC)?

A

A technique that creates duplicate copies of records allowing safe reading and updating of data simultaneously.

22
Q

How does MVCC work?

A
  • Every database record has a version number
  • Concurrent reads happen against the highest version
  • Write operations operate on a copy of the record
  • Version id increments after a successful write
23
Q

What is the difference between MVCC and locking?

A

MVCC does not lock records; it creates new versions for write operations, allowing concurrent reads.

24
Q

What are the drawbacks of MVCC?

A
  • Difficult to implement concurrent update control methods
  • Database size may increase due to multiple record versions
25
What is optimistic concurrency control (OCC)?
A method assuming multiple transactions can complete without interfering, using timestamps and validation.
26
What are the phases of optimistic concurrency control?
* Begin * Modify * Validate * Commit/Rollback
27
What is the 2-phase locking (2PL) technique?
A concurrency control method that divides locking and unlocking operations into expansion and contraction phases.
28
What are the four transaction isolation levels defined in the ANSI/ISO SQL standard?
* Read uncommitted * Read committed * Repeatable read * Serializable read
29
Define deadlock.
Multiple processes or transactions are waiting for resource allocation infinitely.
30
What happens in a deadlock scenario?
Transactions wait indefinitely without making progress due to locked resources.
31
What is the first cause of deadlock?
Circular wait, where each transaction is waiting for a resource held by another.
32
What is one solution to deadlock?
Implementing a deadlock detection algorithm to identify and resolve deadlocks.