Transaction Management and Concurrency Control

0.0(0)
studied byStudied by 0 people
full-widthCall with Kai
GameKnowt Play
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
Card Sorting

1/52

flashcard set

Earn XP

Description and Tags

Question–Answer flashcards covering key concepts from the lecture on transaction management, ACID properties, logging, locking mechanisms, deadlocks, timestamping, optimistic control, and IBM DB2 isolation levels.

Study Analytics
Name
Mastery
Learn
Test
Matching
Spaced

No study sessions yet.

53 Terms

1
New cards

Transaction

A logical unit of work that must be entirely completed or entirely aborted, with no intermediate states.

2
New cards

What does a database request correspond to in an application program?

A single SQL statement.

3
New cards

When a transaction is successful, how does it affect the database?

It moves the database from one consistent state to another consistent state.

4
New cards

How does a DBMS handle a transaction that cannot complete?

It restores the database to its previous consistent state (rollbacks).

5
New cards

Who is ultimately responsible for a transaction’s correctness?

The end user or programmer.

6
New cards

Name the five key properties summarized by ACID + S.

Atomicity, Consistency, Isolation, Durability, and Serializability.

7
New cards

All operations must complete; otherwise the transaction is aborted.

Atomicity

8
New cards

A transaction must preserve database integrity; if violated, the transaction is aborted.

Consistency

9
New cards

Data being used by one transaction cannot be used by another until the first finishes

Isolation

10
New cards

Once a transaction commits, its changes are permanent even if the system fails.

Durability

11
New cards

That interleaved (concurrent) schedules of transactions yield consistent results equivalent to some serial order.

Serializability

12
New cards

Which SQL commands terminate a transaction?

COMMIT and ROLLBACK.

13
New cards

What happens when any action within a transaction fails?

The DBMS issues a ROLLBACK, returning the database to its pre-transaction state.

14
New cards

What is the purpose of the transaction log?

To keep a record of all transactions that update the database for recovery and auditing.

15
New cards

List three pieces of information stored for each log entry of an update.

The operation (insert/update/delete), the affected table, and the before-and-after values of changed fields.

16
New cards

The coordination of simultaneous transaction execution in a multi-user environment.

Concurrency Control

17
New cards

Two concurrent transactions update the same data; the update made by the first transaction is overwritten (lost)

Lost Update Problem.

18
New cards

A transaction reads data modified by another transaction that later rolls back, leaving inconsistent data.

Uncommitted Data (dirty read) problem.

19
New cards

A transaction reads data before and after another concurrent transaction changes it, producing inconsistent results.

Inconsistent Retrievals problem.

20
New cards

It orders the operations of concurrent transactions to ensure serializability. S

It orders the operations of concurrent transactions to ensure serializability. Scheduler

21
New cards

What does a lock guarantee?

Exclusive use of a data item to the transaction that holds the lock.

22
New cards

The level at which data items are locked: database, table, page, row, or field.

lock granularity.

23
New cards

When is database-level locking suitable?

For batch processing where only one transaction needs the database.

24
New cards

Why is database-level locking unsuitable for multi-user environments?

It prevents all other transactions from accessing any table, greatly reducing concurrency.

25
New cards

What does table-level locking allow other transactions to do?

Access other tables in the same database that are not locked.

26
New cards

What happens if many row locks on the same page are requested?

The DBMS may escalate row locks to a page lock.

27
New cards

What is a binary lock?

A lock that can be in only two states: locked (1) or unlocked (0).

28
New cards

What is an exclusive lock?

A lock that gives a single transaction sole access to a data item, used when updates may conflict.

29
New cards

What is a shared lock?

A lock that allows multiple transactions to read the same data item simultaneously, provided no exclusive lock exists.

30
New cards

Why do shared/exclusive locks increase lock-manager overhead?

The manager must check lock types, handle READLOCK, WRITELOCK, UNLOCK, and support upgrades/downgrades.

31
New cards

What are the two phases of the Two-Phase Locking (2PL) protocol?

Growing phase (acquiring locks) and shrinking phase (releasing locks).

32
New cards

Does Two-Phase Locking prevent deadlocks?

No; it guarantees serializability but still allows deadlocks to occur.

33
New cards

State one rule of the 2PL protocol regarding unlock operations.

No unlock operation may precede a lock operation in the same transaction.

34
New cards

Define a deadlock.

A situation where two transactions wait indefinitely for each other to release locks they need.

35
New cards

Name the three basic deadlock control techniques.

Deadlock prevention, deadlock detection, and deadlock avoidance.

36
New cards

What is the main idea behind timestamping methods for concurrency control?

Assign each transaction a unique, increasing timestamp to order all operations.

37
New cards

What two properties must transaction timestamps satisfy?

Uniqueness and monotonicity (always increasing).

38
New cards

Briefly differentiate Wait/Die from Wound/Wait schemes.

Both decide which transaction rolls back in conflict: Wait/Die lets older wait or younger die; Wound/Wait lets older wound (force rollback) younger, younger waits for older.

39
New cards

What assumption underlies optimistic concurrency control?

Most transactions will not conflict, so they run without locks until commit time.

40
New cards

List the three phases of an optimistic concurrency protocol.

Read phase, Validation phase, and Write phase.

41
New cards

Which four problems does IBM DB2 identify without concurrency control?

Lost update, Uncommitted read, Non-repeatable read, and Phantom read.

42
New cards

Name the four DB2 isolation levels (acronyms).

UR, CS, RS, RR.

43
New cards

What is Uncommitted Read (UR) also called, and what risk does it allow?

Dirty read; it allows reading data modified but not yet committed by other transactions.

44
New cards

What does Cursor Stability (CS) lock and for how long when a row is read only?

It locks the current cursor row until another row is fetched or the unit of work ends.

45
New cards

What enhancement does Currently Committed (CC) add to Cursor Stability?

Readers can see the last committed version even while a writer holds the row, improving concurrency.

46
New cards

What rows are locked under Read Stability (RS)?

All rows retrieved within the unit of work and all rows that qualify for the cursor's result set.

47
New cards

Which isolation level offers the highest locking and least concurrency in DB2?

Repeatable Read (RR).

48
New cards

At what levels can isolation be set in DB2?

Session, connection, or individual SQL statement.

49
New cards

How is statement-level isolation specified in SQL?

By appending WITH {UR | CS | RS | RR} to the SELECT statement.

50
New cards

What is lock escalation in DB2?

Automatic replacement of many row locks with a table lock when memory thresholds are exceeded.

51
New cards

Which two configuration parameters affect lock escalation?

LOCKLIST (total lock memory) and MAXLOCKS (percentage one application can use).

52
New cards

What does the LOCKTIMEOUT parameter control?

How long an application waits for a lock before timing out; default is -1 (infinite).

53
New cards

How can a single connection override LOCKTIMEOUT at runtime?

By setting the CURRENT LOCK TIMEOUT register with SET LOCK TIMEOUT.