Chap 20. Lock Architecture
description
Transcript of Chap 20. Lock Architecture
Chap 20. Lock ArchitectureChap 20. Lock Architecture
Written by Yong-soon Kwon
Summerized By Sungchan Park @ IDS Lab.
2008-07-25
Copyright 2008 by CEBT
LockLock
Lock
Ensure data consistency all resources in DB
in parallel or concurrent executing environment
– Enqueue
Long term lock mechanism(table, …)
– Latch
Short term lock mechanism(memory, …)
Center for E-Business Technology
Copyright 2008 by CEBT
EnqueueEnqueue
Enqueue
Acquires lock for long time
Used in managing shared resources
Served by Oracle kernel
Enqueue types
– Managed Enqueue
Oracle DB level
– Client Enqueue
DML
Type
TM : table level lock
TX : row level lock
Center for E-Business Technology
Copyright 2008 by CEBT
Enqueue: Enqueue ModeEnqueue: Enqueue Mode
Enqueue Mode
RS : Lmode 2
– Lock for rows selected by query
RX : Lmode 3
– Table lock when DML
S : Lmode 4
– Lock for reference integrity
SRX : Lmode 5
– On delete cascade
X : Lmode 6
– Row lock when DML
Center for E-Business Technology
Copyright 2008 by CEBT
Enqueue Mode CompatibilityEnqueue Mode Compatibility
Center for E-Business Technology
RS RX S SRX X
RS o o o o x
RX o o x x x
S o x o x x
SRX o x x x x
X x x x x x
Copyright 2008 by CEBT
Resource TableResource Table
Center for E-Business Technology
Copyright 2008 by CEBT
Resource StructureResource Structure
Resource Structure Identifier
– <Enqueue Type-ID1-ID2>
Owner
– Sessions own this resource
Waiter
– Sessions wait this resource
Converter
Center for E-Business Technology
Copyright 2008 by CEBT
Enqueue Operation ScenarioEnqueue Operation Scenario
Center for E-Business Technology
Copyright 2008 by CEBT
Checking EnqueueChecking Enqueue
Center for E-Business Technology
Copyright 2008 by CEBT
LatchLatch
Latch
Acquires lock for short time
Ensure data consistency on memory
Fast, low cost
Type
– Solitary latch
– Latch set
Parent latch + Child latch
Center for E-Business Technology
Copyright 2008 by CEBT
Acquiring LatchAcquiring Latch
Acquring latch
Willing to wait
No wait
Latch spin
Yield CPU to other process
– not deleting process context(sleeping)
Center for E-Business Technology
Copyright 2008 by CEBT
Latch ScenarioLatch Scenario
Center for E-Business Technology
Copyright 2008 by CEBT
Checking Latch with ContentionChecking Latch with Contention
Center for E-Business Technology