Chapter 8: Concurrency Control on Relational Databases - PowerPoint PPT Presentation

1 / 13
About This Presentation
Title:

Chapter 8: Concurrency Control on Relational Databases

Description:

Transaction Chopping. Assumption: ... Definition 8.25 (Transaction chopping) ... Definition 8.28 (Correct chopping) ... – PowerPoint PPT presentation

Number of Views:137
Avg rating:3.0/5.0
Slides: 14
Provided by: escome
Category:

less

Transcript and Presenter's Notes

Title: Chapter 8: Concurrency Control on Relational Databases


1
Chapter 8 Concurrency Control on Relational
Databases
  • 8.2 Predicate-Oriented Concurrency Control
  • 8.3 Relational Update Transactions
  • 8.4 Exploiting Transaction-Program Knowledge
  • 8.5 Lessons Learned

Knowledge without wisdom is a load of books on
the back of an ass. (Japanese proverb)
2
Phantom Problem
Update transaction t
Retrieval transaction q
  • Delete From Emp
  • Where Department Service
  • And Position Manager
  • Insert Into Emp Values
  • (Smith, Service, Manager, 40000)
  • (c) Update Emp Set Department Sales
  • Where Department Service
  • And Position ltgt Manager
  • Insert Into Emp Values
  • (Stone, Service, Clerk, 13000)

Select Name, Position, Salary From Emp Where
Department Service
Retrieval transaction p
Select Name, Position, Salary From Emp Where
Department Sales
  • Observations
  • Interleaving q with t leads to inconsistent read
    known as phantom problem
  • Locking existing records cannot prevent this
    problem

3
Predicate Locking
  • Associate with each operation on table R(A1,
    ..., An)
  • a set C of conditions that covers a set H(C) of
    existing or conceivable tuples
  • with H(C) ? ? dom(A1) ? ... ? dom(An) ?
    satisfies C
  • Each operation locks its H(C)
  • Update operations need to lock pre- and
    postcondition H(C) and H(C)

Example Ca Department Service ? Position
Manager Cb NameSmith? DepartmentService?
PositionManager? Salary40000 Cc Department
Service? Position ? Manager Cc Department
Sales? Position ? Manager Cd NameStone?
DepartmentService? PositionClerk?
Salary13000 Cq Department Service Cp
Department Sales

H(Ca)?H(Cq)??, H(Cb)?H(Cq)??, H(Cc)?H(Cq)??,
H(Cd)?H(Cq)?? H(Cc) ?H(Cq)? H(Ca)?H(Cp)H(Cb)?H(
Cp)H(Cc)?H(Cp)H(Cd)?H(Cp)? H(Cc)?H(Cp)??
4
Precision Locking
  • Predicate locks on predicates Ct and Ct
  • on behalf of transactions t and t in modes mt
    and mt
  • are compatible if
  • t t or
  • both mt and mt are read (shared) mode or
  • H(Ct) ? H(Ct) ?
  • Testing whether H(Ct) ? H(Ct) ? is
    NP-complete
  • For preventing the phantom problem it is
    sufficient that
  • queries lock predicates and
  • insert, update, and delete operations lock
    individual records, and
  • compatibility is checked by testing that an
    update-affected record
  • does not satisfy any of the query predicate
    locks


5
Chapter 8 Concurrency Control on Relational
Databases
  • 8.2 Predicate-Oriented Concurrency Control
  • 8.3 Relational Update Transactions
  • 8.4 Exploiting Transaction-Program Knowledge
  • 8.5 Lessons Learned

6
Chapter 8 Concurrency Control on Relational
Databases
  • 8.2 Predicate-Oriented Concurrency Control
  • 8.3 Relational Update Transactions
  • 8.4 Exploiting Transaction-Program Knowledge
  • 8.5 Lessons Learned

7
Motivation Short Transactions Are Good
Debit/credit t1 r(A1)w(A1)r(B1)w(B1) t2
r(A3)w(A3)r(B1)w(B1) t3 r(A4)w(A4)r(B1)w(B1)
t11 r(A1)w(A1) t12 r(B1)w(B1) t21
r(A3)w(A3) t22 r(B1)w(B1) t31 r(A4)w(A4) t32
r(B1)w(B1)
decompose ?
Balance t4 r(A2) t5 r(A4)
Audit t6 r(A1)r(A2)r(A3)r(B1)r(A4)r(A5)r(B2)
t61 r(A1)r(A2)r(A3)r(B1) t62 r(A4)r(A5)r(B2)
8
Transaction Chopping
Assumption all potentially concurrent app
programs are known in advance and their structure
and resulting access patterns can be precisely
analyzed
Definition 8.25 (Transaction chopping) A
chopping of transaction ti is a decomposition of
ti into pieces ti1, ..., tik s.t. every step of
ti is contained in exactly one piece and the step
order is preserved.
  • Definition 8.28 (Correct chopping)
  • Achopping of Tt1, ..., tn is correct if every
    execution of the transaction
  • pieces is conflict-equivalent to a serial history
    of T under a protocol with
  • transaction pieces obey the execution
    precedences of the original programs.
  • each piece is executed as a unit under a CSR
    scheduler.

9
Chopping Graph
  • Definition 8.26 (Chopping graph)
  • For a chopping of transaction set T the chopping
    graph C(T) is
  • an undirected graph s.t.
  • the nodes of C(T) are the transaction pieces
  • for two pieces p, q from different transactions
    C(T) contains a
  • c edge between p and p if p and q contain
    conflicting operations
  • for two pieces p, q from the same transaction
    C(T) contains an s edge

Theorem 8.29 A chopping is correct if the
associated chopping graph does not contain an sc
cycle (i.e., a cycle that involves at least one s
edge and at least one c edge.
Example 8.27 t1 r(x)w(x)r(y)w(y) t2
r(x)w(x) t3 r(y)w(y)
s
C(T)
t11 r(x)w(x) t12 r(y)w(y)
t11
t12
c
c
t2
t3
10
Chopping Example
t1 r(A1)w(A1)r(B1)w(B1) t2 r(A3)w(A3)r(B1)w(B1)
t3 r(A4)w(A4)r(B1)w(B1) t4 r(A2) t5 r(A4) t6
r(A1)r(A2)r(A3)r(B1)r(A4)r(A5)r(B2)
t61 r(A1)r(A2)r(A3)r(B1) t62 r(A4)r(A5)r(B2)
c
t12
t2
t3
t11
t11 r(A1)w(A1) t12 r(B1)w(B1)
s
c
c
c
c
c
t4
t5
t61
t62
s
11
Applicability of Chopping
Directly applicable to straight-line,
parameter-less SQL programs with predicate locking
Needs to conservatively derive covering program
for parameterized SQL, if-then-else and loops,
and needs to be conservative about c edges
Example Select AccountNo From Accounts
Where AccountTypesavings And City x if
not found then Select AccountNo From
Accounts Where AccountTypechecking And City
x fi ? Select AccountNo From Accounts
Where AccountTypesavings Select AccountNo
From Accounts Where AccountTypechecking
12
Chapter 8 Concurrency Control on Relational
Databases
  • 8.2 Predicate-Oriented Concurrency Control
  • 8.3 Relational Update Transactions
  • 8.4 Exploiting Transaction-Program Knowledge
  • 8.5 Lessons Learned

13
Lessons Learned
  • Predicate locking is an elegant method for
    concurrency control
  • on relational databases, but has non-negligible
    overhead
  • ? record locking (plus index key locking) for
    2-level schedules
  • remains the practical method of choice
  • Concurrency control may exploit additional
    knowledge about
  • limited operation types, integrity
    constraints, and program structure
  • Transaction chopping is an interesting tuning
    technique
  • that aims to exploit such knowledge
Write a Comment
User Comments (0)
About PowerShow.com