10. Transactions and Concurrency I Flashcards

1
Q

3 main types of concurrency issues in DBMS

A

• Inconsistent Reads: A user reads only part of what was updated.

– User 1 updates Table 1 and then updates Table 2.

– User 2 reads Table 2 (which User 1 has not updated yet) and then Table 1 (which User 1 already updated) so it reads the database in an intermediate state.

• Lost Update: Two users try to update the same record so one of the updates gets lost. For example:

– User 1 updates a toy’s price to be price * 2.

– User 2 updates a toy’s price to be price + 5, blowing away User 1’s update.

• Dirty Reads: One user reads an update that was never committed.

– User 1 updates a toy’s price but this gets aborted.

– User 2 reads the update before it was rolled back.

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

Transaction - def

A

A transaction is a sequence of multiple actions that should be executed as a single, logical, atomic unit.

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

ACID properties of transactions

A
  • Atomicity: A transaction ends in two ways: it either commits or aborts. Atomicity means that either all actions in the Xact happen, or none happen.
  • Consistency: If the DB starts out consistent, it ends up consistent at the end of the Xact.
  • Isolation: Execution of each Xact is isolated from that of others. In reality, the DBMS will interleave actions of many Xacts and not execute each in order of one after the other. The DBMS will ensure that each Xact executes as if it ran by itself.
  • Durabilty: If a Xact commits, its effects persist. The effects of a committed Xact must survive failures.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What is a transaction schedule? Which operations does it consist of?

A

Transaction schedules show the order that operations are executed in. These operations include: Begin, Read, Write, Commit and Abort.

E.g. if one transaction has operations O1, O2, and another transaction has operations O4, O5 some possible schedules are:

O1, O4, O5, O2

O1, O2, O4, O5

O4, O5, O1, O2

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

What is a serial schedule?

Main advantage and drawback? The main practical goal?

A

Serial schedule ensures that we run all the operations of one transaction to completion before beginning the operations of next transaction.

Pros: It definitely ensures isolation by def.

Cons: it is not efficient and completely eliminates concurrency.

The main practical goal is to find a schedule that is equivalent to serial but allows some concurrency.

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

3 rules of transaction schedule equivalence

A

For schedules to be equivalent they must satisfy the following three rules:

  1. They involve the same transactions
  2. Operations are ordered the same way within the individual transactions
  3. They each leave the database in the same state
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What is a serializable transaction schedule?

A

a schedule whose results are equivalent to a serial schedule

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

Which transaction operations may conflict with each other? 3 rules.

A

For two operations to conflict they must satisfy the following three rules:

  1. The operations are from different transactions
  2. Both operations operate on the same resource
  3. At least one operation is a write
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

Transaction schedule conflict equivalence - def.

A

When two schedules order their conflicting operations in the same way the schedules are said to be conflict equivalent, which is a stronger condition than being equivalent.

I.e. all conflict equivalent operations are equivalent,

but NOT all equivalent are conflict equivalent.

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

Conflict serializable transaction schedule - def.

A

a schedule that is conflict equivalent to some serial schedule.

Conflict serializable schedule is always serializable. So it always maintains transaction isolation property + may allow some concurrency, which is our main goal!

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

dependency graph - describe.

Why do we need it?

A

Dependency graphs have the following structure:

  • One node per Xact
  • Edge from T_i to T_j if:

– an operation O_i of T_i conflicts with an operation O_j of T_j

– O_i appears earlier in the schedule than O_j

Theorem: A schedule is conflict serializable if and only if its dependency graph is acyclic. So all we have to do is check if the graph is acyclic to know for sure that it is serializable!

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