Chapter 10 - Transaction Management and Concurrency Control

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

1/22

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.

23 Terms

1
New cards

Difference between request and transaction

Transaction - logical unit of work that must be entirely completed or aborted. No intermediate states acceptable

DB Request - equivelent of single SQL statement in transaction

Transactions are formed by two or more DB requests

2
New cards

_____ are formed by two or more DB requests

Transactions

3
New cards

What is concurrency control

coordinating the simulatneous execution of transactions in a multiuser DB system

Objective: ensure serializability of transactions in multi-user DB environment

4
New cards

Why is concurrency control important?

Simultaneous execution of transactions over a shared DB can create several data integrity/consistency problems

5
New cards

Concurrency control seeks to solve which 3 problems?

1. Lost updates

-two concurrent transactions update same data element... one is lost

2. Uncommitted data

-two transactions executed concurrently, first rolled back after second accessed uncommitted data

3. Inconsistent retrievals

-transactions might read some data before they are changed by another transaction, reading different data after the change

6
New cards

What is the purpose of the scheduler?

established the order in which the opeations are executed within concurrent transactions

7
New cards

What is a lock

Guarantees unique access to data item by transaction

8
New cards

Why do we need locks?

To prevent anther transaction from reading inconsistent data

9
New cards

Different lock levels

DB level

-entire DB locked while one person is updating... bad idea

Table level

-entire table is locked

-still bad idea

Page level

-diskpage locked

Row level

-concurrent Ts can access different rows of same table

Field level

-can access same rw as long as they use different attributes in that row

10
New cards

What type of lock is usually most useful

Row-level

11
New cards

What are the types of locks?

Binary

Shared/Exclusive

12
New cards

What are binary locks?

only have two states: locked or unlocked

13
New cards

What are exclusive locks?

access is reserved specifically for the transaction that locked the object

only some have access until T is over

Ex: when DB reads 'insert into' or any similar command, it will lock until T is done

14
New cards

Shared lock

concufrent transactions granted read access on basis of a common lock

15
New cards

Problems exclusive/binary locks can cause

1. resulting transaction schedule might not be serializable

2. DEADLOCKS

16
New cards

What is two phased locking

-defines how transactions acquire and relinquish locks

-ensures serializabilty

17
New cards

Two phases in two phase locking

1. Growing phase

-T acquires all required locks without unlocking any data

2. Shrinking

-T releases all locks and cannot obtain new lock

18
New cards

What are deadlocks

two transactions wait indefinitely for other to unlock data

19
New cards

two-phase locking ensures ______ and prevents ____

serializability

deadlocks

20
New cards

3 techniques to control deadlocks

1. Prevention

2. Detection

3. Avoidance

21
New cards

Deadlock prevention

Transaction requesting new lock is aborted when there is a possibility that deadlock can occur

22
New cards

Deadlock detection

DBMS periodically tests DB for deadlocks

If found, "victim" transaction aborted and other continues

As soon as deadlock happens, intervenes

23
New cards

Deadlock avoidance

Transaction must obtain all locks needed before can be executed

Avoids rolling back of conflicting transactions by requiring locks be obtained in succession

Takes a lot more processing ---> increases response times, not good for transaction heavy environmnet