COMSCI 2200: Concurrency Control

0.0(0)
studied byStudied by 16 people
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
Card Sorting

1/44

encourage image

There's no tags or description

Looks like no tags are added yet.

Study Analytics
Name
Mastery
Learn
Test
Matching
Spaced

No study sessions yet.

45 Terms

1
New cards

Transaction

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

2
New cards

Transaction

A unit of performing a series of read and write operations in a database, which should be

performed at the same time.

3
New cards

Atomicity

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

4
New cards

Consistency

The transaction result should always be the same expected value.

A transaction should be controlled using Lock, Timestamp, Validation, etc. to prevent other transactions from intervening in the middle of processing the transaction.

5
New cards

Isolation

Another transaction should not intervene and process the data until

transaction commit or rollback isissued.

6
New cards

Durability

The persistence of a successful transaction should be guaranteed. In this case, the data should be restored using the forward recovery algorithm.

7
New cards

Transaction commit operation:

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

8
New cards

Transaction rollback operation:

An operation that restores all data values that have been modified by a transaction so far to the state prior to executing the transaction (that is, aborting the transaction), when the transaction cannot continue due to a fatal error in the middle of the transaction or because the user issues a rollback command.

9
New cards

Implementation of transaction concurrency:

Simultaneous execution of transactions can increase concurrency by increasing the transaction throughput and system utilization ratio and by reducing latency.

10
New cards

Executing a transaction as quickly as possible:

If a transaction takes too long, there is a high possibility that conflicts and deadlocks will occur due to the long locking time. Locking should be maintained long enough to ensure transaction serialization, but should be executed quickly enough so as not to deteriorate performance at the same time.

11
New cards

Serializable Schedule

Means that even if each transaction is executed at the

same time, the result is the same as the sequential execution of the

transaction.

12
New cards

Concurrency Control

A function that enables the successful execution of several transactions at the same time in a database system that supports a multi-user environment.

13
New cards

Concurrency Control

A database system that supports a multi-user environment must have this function, which is also called concurrency control.

14
New cards

To create a serializable schedule or ensure the possibility of transaction serialization.

Purposes of Concurrency Control (1)

15
New cards
16
New cards

To guarantee the maximum sharing level, minimum response time, and maximum system activity.

Purposes of Concurrency Control (2)

17
New cards

To ensure data integrity and consistency.

Purposes of Concurrency Control (3)

18
New cards

Lost Update

• Occurs when transactions update the same data simultaneously.

• Occurs when the later transaction overwrites the update value before the previous transaction has completed the transaction after updating the data.

19
New cards

Dirty Read

• Other transactions refer to the intermediate execution result of a transaction.

20
New cards

Inconsistency

• A database remains inconsistent when two transactions are executed at the same time.

21
New cards

Cascading Rollback

• When a specific transaction cancels processing if data is shared by multiple transactions, the part processed by other transactions cannot be cancelled.

22
New cards

Unrepeatable Read

• When a transaction executes the same query twice, the query results differ because other transactions have modified or deleted the value in the middle.

23
New cards

1.Lock-based technique

2.Timestamp-based technique

3.Multi-version technique

4.Verification (optimistic) based technique

Concurrency Control Technique

24
New cards

Lock-Based Technique

Lock Based Protocols in DBMS is a mechanism in which a transaction

cannot Read or Write the data until it acquires an appropriate lock.

Lock based protocols help to eliminate the concurrency problem in DBMS for simultaneous transactions by locking or isolating a particular transaction to a single user.

25
New cards
26
New cards

Lock-Based Technique

A lock is a data variable which is associated with a data item. This lock

signifies that operations that can be performed on the data item. Locks in DBMS help synchronize access to the database items by concurrent transactions.

27
New cards

Lock-Based technique

All lock requests are made to the concurrency-control manager. Transactions proceed only once the lock request is granted.

28
New cards

Timestamp-Based Technique

An algorithm which uses the System Time or Logical Counter as a timestamp to serialize the execution of concurrent transactions. The Timestamp-based protocol ensures that every conflicting read and write operations are executed in a timestamp order.

29
New cards

Timestamp-Based Technique

The older transaction is always given priority in this method. It uses system time to determine the time stamp of the transaction. This is the most commonly used concurrency protocol.

30
New cards

Timestamp-Based Technique

Lock-based protocols help you to manage the order between the conflicting transactions when they will execute. Manage conflicts as soon as an operation is created.

31
New cards

Multi-Version technique

A database optimization technique that creates duplicate copies of records so that data can be safely read and updated at the same time.

32
New cards

Multi-Version Technique

When implemented properly by a DBMS, provides the following benefits:

 diminished need for database locks;

 fewer database access contention issues;

 improved read access performance;

 continued record isolation for write operations; and

 reduced number of database deadlocks.

33
New cards

Multi-Version Technique

DBMS reads and writes don’t block each other.

34
New cards

1. Every database record has a version number.

2. Concurrent reads happen against the record with the highest version number.

3. Write operations operate on copy of the record, not the record itself.

4. Users continue to read the older version while the copy is updated.

5. After the write operation is successful, the version id is incremented.

6. Subsequent concurrent reads use the updated version.

7. When a new update occurs, a new version is again created, continuing the cycle.

HOW DOES AN MVCC DATABASE WORK?

35
New cards
  • Unlike traditional a DMBS, multiversion concurrency control does not lock a record when a write operation is about to occur. Instead, a new version of the record, with an incremented version number, is created.

  • Users can continue to read the old version of the record while the new record is transitionally edited and updated. This eliminates the need for locks, as well as contention and deadlock issues.

  • When the new version of the record is committed to the database, all future read operations work on the updated version. New write operations again create a new version, and the cycle continues.

Difference between MVCC vs. Locking

36
New cards
  • While MVCC offers many benefits, there are two key drawbacks to multiversion concurrency control:

  • Concurrent update control methods are difficult to implement.

  • The database grows in size and becomes bloated by multiple versions of DBMS records.

  • For the user, or even the developer, the complexity involved to implement MVCC concurrency control methods is completely hidden, as the functionality is provided by the database vendor.

  • The developer can write SQL, and the end user can consume applications as they normally would. The fact that the DBMS uses multiversion concurrency control behind the scenes is completely transparent to them.

WHAT ARE THE DRAWBACKS TO MULTIVERSION CONCURRENCY

CONTROL (MVCC)?

37
New cards

Optimistic Concurrency Control or Optimistic Locking

is a concurrency control method applied to transactional systems such as relational database management systems and software transactional memory. OCC assumes that multiple transactions can frequently complete without interfering with each other. While running, transactions use data resources without acquiring locks on those resources.

38
New cards

Begin

Modify

Validate

Commit Rollback

Optimistic concurrency control transactions involve these phases

39
New cards

Modify

Read database values, and tentatively write changes.

40
New cards

Validate

Check whether other transactions have modified data that this transaction has used (read or written). This includes transactions that completed after this transaction's start time, and optionally, transactions that are still active at validation time.

41
New cards

Begin

Record a Timestamp marking involve these phases

42
New cards

Commit/Rollback

If there is no conflict, make all changes take effect. If there is a conflict, resolve it, typically by aborting the transaction, although other resolution schemes are possible. Care must be taken to avoid a time-of-check to time-of-use bug, particularly if this phase and the previous one are not performed as a single atomic operation.

43
New cards

2-Phase Locking Technique

controls concurrency by guaranteeing serialization and follows the 2PL protocol, which performs jobs by dividing ‘lock’ and ‘unlock’ operations into the expansion and contraction phases.

44
New cards

Expansion Phase

A phase in which a transaction can perform locking only, and cannot perform unlocking.

45
New cards

Contraction Phase

A phase in which a transaction can perform unlocking only, and cannot perform locking.