Back to marketplace

Concurrency Control

No description yet. This curated deck is ready for daily study.

Total cards: 24•Content version: v4•Public deck•Updated: 8/1/2026

Card preview (24)

#1
Front (Question)

Ghost update type b: when does it happen. Can it be managed with 2PL?

Back (Answer)

On insert or group by. 2PL cannot managed it, predicate locking yes.

#2
Front (Question)

Definition of transaction

Back (Answer)

A sequence of read and write operations characterized by the same TID

#3
Front (Question)

Schedule definition

Back (Answer)

sequence of read/write operations presents by concurrent transactions Concurrency control accepts or rejects schedules to avoid anomalies, the scheduler though has to accept or reject op. execution without knowing the outcome of the transactions (abort/commit)

#4
Front (Question)

Serializable schedule

Back (Answer)

Si is serializable when Si is equivalent to an arbitrary serial shedule of the same transactions.

#5
Front (Question)

View equivalence and view serializable schedule

Back (Answer)

Two schedules are view equivalent if they have the same reads-from set and the same final write set. A schedule is view serializable if it is view equivalent to an arbitrary serial schedule of the same transactions. Prevents: lost update: inconsistent read, ghost update (a). Detecting view equivalence to a given schedule is O(n). Detecting view equivalence to an arbitrary serial schedule is NP-complete (not feasible).

Card back image
#6
Front (Question)

Scheduler

Back (Answer)

• Block of the concurrency control maanger • is in charge of deciding if and when read/write requests can be satisfiedd Without a scheduler we may have correctness problems

#7
Front (Question)

Lost Update

Back (Answer)

Card back image
#8
Front (Question)

Dirty Read

Back (Answer)

Card back image
#9
Front (Question)

Inconsistent read

Back (Answer)

Value is read 2 times, and reads different values during the same T.

Card back image
#10
Front (Question)

Ghost update (a)

Back (Answer)

T1 only partially observes the effect of T2. All objects are already present. Ghost updates result from inconsistent reads.

Card back image
#11
Front (Question)

Ghost update (b)

Back (Answer)

Inconsistent read. A new set of objects are inserted by another transaction.

Card back image
#12
Front (Question)

Commit projection

Back (Answer)

Is a simplifying hypothesis: the schedule contains only transactions performing commit

#13
Front (Question)

Equivalence classes

Back (Answer)

• View equivalence • Conflict equivalence • 2PL • Timestamp equivalence Each detecs a set of acceptable schedules, and is characterized by a different complexity in detecting equivalence.

#14
Front (Question)

Conflict equivalence, conflict serializable

Back (Answer)

Conflicting actions: Action Ai is in conflict with Aj (i != j) if both action operate on the same object and at least one of them is a write: • Read-Write conflicts (RW or WR) • Write-Write conflicts Two schedules are conflict equivalent if they have the same conflict set and each conflict pair is in the same order in both schedules. Conflict serializable: if it is equivalent to an arbitrary serial schedule of the same transactions. CSR: conflict serializable schedules. Detecting conflict serializability is possible through a conflict graph. CSR is a subset of VSR.

Card back image
#15
Front (Question)

Conflict graph

Back (Answer)

A node for each transaction. An edge Ti -> Tj if: • there exist at least a conflict between the two • Ai preceeds Aj Checking for cycles is O(V + E).

#16
Front (Question)

2PL

Back (Answer)

2 Phase Locking A lock may block others from accessing a resource. Locks: Write-Lock, Read-Lock. Read-Locks are shared. Write-Locks are exclusive. Lock escalation: R-Lock followed by W-lock on the same data. Used by most DBMS. Characterized by two phases: • Growing: needed locks acuired • Shrinking: all locks are released. 2PL is a subeset of CSR.

#17
Front (Question)

2PL: Lock manager

Back (Answer)

Scheduler becomes lock manager: • receives transaction requests and grants locks based on locks already granted. • when the lock is not granted the transaction is put in waiting state, the wait terminates when the locked resource is freed. • when a timeout runs out while a transaction is still waiting: extracts the transactions from waiting list, resumes it, returns an error code. • in the latter case the transaction may perform rollback (and possibly restart) or request again the same lock after some time (without releasing currently held resources) Lock manager exploits a lock table and the conflict table.

Card back image
#18
Front (Question)

Strinct 2PL

Back (Answer)

Transactions locks may be releasd only at the end of the transaction (after commit/abort). -> at the end of the transaction data is stable (this avoids dirty read completely). Allows the dropping of the commit projection hypothesis.

#19
Front (Question)

2PL: Probability of conflict

Back (Answer)

K * M / N K = active transactions M = average number of objects accessed by a transaction N = is the number of objects in the database

#20
Front (Question)

Hierarchical locking

Back (Answer)

Table locks can be acquired at different granularities: • Table • Group of tuples (fragment): physical or logical • Single tuple • Single field in a tuple It is an extension of traditional locking, charaterized by a larger set of primitives: Shared lock (SL) eXclusive lock (XL) Intention of Shared Lock (ISL): intention of shared locking on node lower in the hierarchy. Intention of eXclusive Lock (IXL): same as ISL, but for exlusive lock Shared lock and Intention of eXclusive Lock(SIXL): shared lock of current object and intetion to get exlusive lock of lower level nodes. Locks are requested startinf from the root, relelased starting from the leafs. To request a SL or ISL need to own ISL or IXL on parent. To request a XL, IXL or SIXL, need own a IXL or SIXL, on its parent.

Card back image
#21
Front (Question)

Selction of lock granularity

Back (Answer)

Depends on application type. If it performs localized reads or updates few objects -> detailed granularity if it performs massive reads or updates -> near root -> rough granularity Effects of granularity: too coorse -> reduces concurrency too fine -> forces overhead on lock manager.

#22
Front (Question)

Predicate locking

Back (Answer)

The only solution capable of addressing Ghost (insert) Update (b). For 2PL a read operation is not in conflict with an insert op. -> new tuple cannot be locked in advance Predicate locking allows locking all data satisfying a given predicate. -> implemented in real systems using locking indices

#23
Front (Question)

SQL2 Standard: Locking

Back (Answer)

There are two transaction types: • read-write • read only: no data or schema modifications, just SL. Isolation levels: • Serializable: predicate locking • Repeatable Read: strict 2PL (no predicate locking) -> repeated reads of existing objects can be correctly repeated, no protection gainst ghost update (b) • Read committed: no 2PL, read lock released ASA object is read. -> data is read only it is committed, dirty reads aboided • Read Uncommitted: only allowed for read only transactions. -> dirty read allowed. Syntax: SET TRANSACTION [ISOLATION LEVEL] [READ ONLY] [READ WRITE] Isolation level may be reduced only for read statements, since write operations are always executed with XLs.

#24
Front (Question)

Deadlock: solutions, how to prevent it, how to detect it

Back (Answer)

Solving: Timeout • Most used solution in commercial systems • After time expires the transaction receives a negative answer and performs rollback. • Particular attention should be taken when choosing the timeout interval: too long (long waiting for resolving deadlock), short (many false positives, overloads the system) Preventing: Pessimistic/Conservative 2PL • All locks are acquired before the transaction starts (may not be possible) • Only younger transactions are allowed to wait Detection: Wait graph • nodes are transactions • a cycle represents a deadlock • used in distributed DBMS

Card back image