chap 20. lock architecture

13
Chap 20. Lock Architecture Chap 20. Lock Architecture Written by Yong-soon Kwon Summerized By Sungchan Park @ IDS Lab. 2008-07-25

Upload: spike

Post on 31-Jan-2016

52 views

Category:

Documents


0 download

DESCRIPTION

Chap 20. Lock Architecture. Written by Yong-soon Kwon Summerized By Sungchan Park @ IDS Lab. 2008-07-25. Lock. Lock Ensure data consistency all resources in DB in parallel or concurrent executing environment Enqueue Long term lock mechanism(table, …) Latch - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: 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

Page 2: Chap 20. Lock Architecture

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

Page 3: Chap 20. Lock Architecture

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

Page 4: Chap 20. Lock Architecture

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

Page 5: Chap 20. Lock Architecture

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

Page 6: Chap 20. Lock Architecture

Copyright 2008 by CEBT

Resource TableResource Table

Center for E-Business Technology

Page 7: Chap 20. Lock Architecture

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

Page 8: Chap 20. Lock Architecture

Copyright 2008 by CEBT

Enqueue Operation ScenarioEnqueue Operation Scenario

Center for E-Business Technology

Page 9: Chap 20. Lock Architecture

Copyright 2008 by CEBT

Checking EnqueueChecking Enqueue

Center for E-Business Technology

Page 10: Chap 20. Lock Architecture

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

Page 11: Chap 20. Lock Architecture

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

Page 12: Chap 20. Lock Architecture

Copyright 2008 by CEBT

Latch ScenarioLatch Scenario

Center for E-Business Technology

Page 13: Chap 20. Lock Architecture

Copyright 2008 by CEBT

Checking Latch with ContentionChecking Latch with Contention

Center for E-Business Technology