tt dafea - PowerPoint PPT Presentation

1 / 50
About This Presentation
Title:

tt dafea

Description:

RAM. ???s????? ap????e?s? (?ata????t?? ?? ??) ?. cache ... Ta d?? e ?a s???e??? ??? ???p???s? (ARIES) ??se?? ?ed? ???? II 2000-2001 ??a??e??a ??t???? ... – PowerPoint PPT presentation

Number of Views:57
Avg rating:3.0/5.0
Slides: 51
Provided by: csU83
Category:
Tags: aries | dafea | ram | the

less

Transcript and Presenter's Notes

Title: tt dafea


1
?e?????? ????aµ???
2
????aµ?? ap? ?p?t???e?
??d? ?p?t????? ??? ?at?????e? ?atast??f? ? ???
t?? µ???µ?? ap????e?s?? (d?s???) ?a?ade??µata
ap?t????? ...
3
?p???µ?t?? ?d??t?te? µ?a? ??s?????a?
?d??t?te? ??s???????
  • ?tomicity (at?µ???t?ta) - e?te ??e? ?? p???e??
    e?te ?aµ?a
  • Consistency (s???pe?a) - d?at???s? s???pe?a? t??
    ??
  • Isolation (ap?µ???s?) - de? ap??a??pte?
    e?d??µesa ap?te??sµata
  • Durability (µ???µ?t?ta ? d????e?a) - µet? t??
    ep?????s? µ?a? d?s?????a? ?? a??a??? de? e??a?
    d??at?? ?a ?a????

4
?p???µ?t?? ?d??t?te? µ?a? ??s?????a?
  • ?tomicity (at?µ???t?ta) ???????S
    ?????????S
  • Consistency (s???pe?a) ????T??????? ???
    ???G???????S??
  • Isolation (ap?µ???s?) ???G??S
    S?????????????S
  • Durability (µ???µ?t?ta ? d????e?a)
    ???????S ?????????S

5
?????e? ????aµ???
  • ?t?µ???t?ta
  • ?? d?s?????e? µp??e? ?a a?a??e???? (Rollback).
  • ?????e?a
  • T? ?a s?µße? a? t? S??? ?ata??e?se??
  • ?p???µ?t? s?µpe??f??? µet? ap? µ?a ap?t???a
  • T1, T2 T3 p??pe? ?a ????? d????e?a
    (redo-epa??????)
  • T4 T5 p??pe? ?a a?a??e???? (undo-a?a??es?)

ap?t???a
T1 T2 T3 T4 T5
6
?????e? ????aµ???
  • ?t?µ???t?ta
  • ??? ep?????µ??e? -- undo -- a?a??es?
  • ?????e?a
  • ep?????µ??e? -- redo -- epa??????

7
?????e? ????aµ???
t? µ??t??? t?? s?st?µat??
se??de?
DB
RAM
ßd st? d?s??
???s????? ap????e?s? (?ata????t?? µ??µ??) ? cache
8
?????e? ????aµ???
  • St?? p?? e????? pe??pt?s?
  • ??e? ?? e??µe??se?? µ?a? d?s?????a? ???f??ta?
    st?? t?p??? ???? e??as?a? t?? d?s?????a?
  • ? ßd e??µe???eta? µ???? af?? µ?a d?s?????a
    ft?se? st? s?µe?? ep?????s?? t??

9
?????e? ????aµ???
  • St?? p?a?µat???t?ta --Steal (flush)
  • ??p??e? e??µe??se?? µ?a? d?s?????a? ???f??ta?
    st?? d?s?? (ßd) p??? ? d?s?????a ep??????e?
  • G?at? ße?t??s? througput
  • ???ß??µa ?t?µ???t?ta (a?a??es? (undo) st??
    pe??pt?s? p?? ? d?s?????a ap?t??e?)

10
?????e? ????aµ???
  • St?? p?a?µat???t?ta -- No Force
  • ??p??e? e??µe??se?? µ?a? d?s?????a? de ???f??ta?
    st?? d?s?? (ßd) a??µa ?a? af?? ? d?s?????a
    ep??????e?
  • G?at? ße?t??s? ?????? ap?d?s??
  • ???ß??µa ?????e?a (epa?????? (redo) st??
    pe??pt?s? p?? t? s?st?µa ap?t??e?)

11
?????e? ????aµ???
No Steal
Steal
Force
??????
?p???µ?t?
No Force
12
?????e? ????aµ???
  • ??e? ?? e??µe??se?? µ?a? d?s?????a? ???f??ta?
    st?? t?p??? ???? e??as?a? t?? d?s?????a? -- ? ßd
    e??µe???eta? µ???? af?? µ?a d?s?????a ft?se? st?
    s?µe?? ep?????s?? t??
  • ete???????sµ?? t?? e??µe??se?? -- deferred
    updates
  • ????? a?a??es?/ µe epa?????? (no undo/redo)
  • ??p??e? e??µe??se?? µ?a? d?s?????a? ???f??ta? st?
    ßd p??? µ?a d?s?????a ft?se? st? s?µe??
    ep?????s?? t??
  • ?µes? e??µ???s? -- immediate updates
  • µe a?a??es?/ µe epa?????? (n? undo/redo)

13
???a?a? ???p?p???s?? Se??d??
  • ?at?????? se??d?? p?? e??a? st? µ??µ? (cache)
  • ??ad??? ??f?? t??p?p???s?? (dirty bit)

14
?µe??????? S?st?µat?? (Log)
  • G?a ?a e??a? d??at? ? a???aµ?? ap? ap?t???e?,
    ?ata??????ta? p????f???e? ??a t?? p???e?? t??
    d?s???????
  • ?p????e???ta? st? d?s??
  • ??p?? p????f???a? ??a??? d?s?????a?
  • e???af? st???e??? (pa???, ??a t?µ?)
  • a?????s? st???e??? (??at?)
  • ep?????s?/a????s?
  • e??a? d??at? ? a?a??es? (undo) ? ? epa??????
    (redo) µ?a? d?s?????a?

15
?µe??????? S?st?µat?? (Log)
  • ?ata????s? t?p?? ????????? (REDO)
  • ?e????e? t?? ??a t?µ? (AFter IMage)
  • ?ata????s? t?p?? ANAI??S? (UNDO)
  • ?e????e? t?? pa??? t?µ? (BeFore IMage)

16
???e???af? ???et?????
?? p??t?????? p??e???af?? e??et????? (Write Ahead
Log) (1) ? ?ata????s? st? log ??a µ?a e???af?
???feta? st? d?s?? p??? ?? a?t?st???e? se??de? ?a
??af??? st? d?s?? (2) ???? t?? ep?????s?
(commit) µ?a? d?s?????a? ??e? ?? ?ata????se?? t??
log p?? t?? af????? ???f??ta? st? d?s??
?? (1) d??e? at?µ???t?ta ?? (2) d??e? d????e?a
17
???e???af? ???et?????
Ta d??µe µ?a s???e???µ??? ???p???s? (ARIES)
18
?µe??????? S?st?µat?? (Log)
Se???a?? e???af? st? log G?a ???e e???af?
st???e???, st? log µ?a ?ata????s? offset, length, old data, new data
µ????
pa??? t?µ? (undo)
ID d?s?????a?
??a t?µ? (redo)
a???µ?? se??da?
??s? st? se??da
19
ARIEL
  • ???e ?ata????s? st? log ??e? ??a µ??ad??? a???µ?
    Log Sequence Number (LSN).
  • LSNs p??ta a???????.
  • ?? log ???feta? st? d?s??. ?? s?st?µa ??at? t?
    µetaß??t? flushedLSN t? µ???st? LSN p?? ???ft??e
    st? d?s?? µ???? t??a

?ata????se?? t?? log ?d? flushed st? d?s??
flushedLSN
Log tail st?? RAM
20
ARIEL
  • ???e se??da ded?µ???? pe????e? ??a?
  • pageLSN t? p?? p??sfat? LSN ??a e???af? se a?t?
    t? se??da
  • WAL ???? ??afte? µ?a se??da,
  • pageLSN ? flushedLSN

?ata????se?? t?? log ?d? flushed st? d?s??
flushedLSN
21
ARIEL ?ata????se?? Log
?ed?a LogRecord
  • ??p?? ?ata????se??
  • Update
  • Commit
  • Abort
  • End
  • Compensation Log Records (CLRs)
  • ??a p???e?? UNDO

???????µe?? LSN ??a t? d?s?????a
???? ??a e???af??
22
ARIEL ???e? d?µ??
  • ???a?a? ??s???????
  • ??a e???af? ??a ???e e?e??? d?s?????a
  • ?ed?a e???af??
  • XID,
  • status, (running/commited/aborted),
  • lastLSN (te?e?ta?? LSN p?? af??? t? d?s?????a).

23
ARIEL ???e? d?µ??
  • ???a?a? ???p?p???µ???? se??d??
  • ??a e???af? ??a ???e t??p?p???µ??? se??da st?
    µ??µ?.
  • ?ed?a e???af??
  • recLSN -- LSN t?? ?ata????s?? t?? log t?? p??t??
    a??a??? st? se??da

24
ARIEL H Ge???? ?????a
LOG
RAM
DB
LogRecords
???a?a? ??s??????? lastLSN status ???a?a?
???p?p???µ???? Se??d?? recLSN flushedLSN
Se??de? ?ed?µ???? se ???e se??da pageLSN
25
ARIEL ?a??de??µa
LSN LOG
begin_checkpoint end_checkpoint update T1
writes P5 update T2 writes P3 T1 abort CLR Undo
T1 LSN 10 T1 End update T3 writes P1 update T2
writes P5
00 05 10 20 30 40
45 50 60
prevLSNs
???a?a? ??s??????? lastLSN status ???a?a?
???p?p???µ???? Se??d?? recLSN flushedLSN
26
ARIEL ?µa?? ??t??es? ??s?????a?
  • ??a a???????a ap? reads writes, p?? te?e??????
    µe commit ? abort.
  • ?p???t??µe ?t? ?? e???af?? st? d?s?? e??a?
    at?µ????
  • ??st??? 2PL ? a?st??? ?????p?????µµata
  • STEAL, NO-FORCE , µe p??e???af? log (Write-Ahead
    Logging)

27
ARIEL ?p?????s? ??s?????a?
1. G???e µ?a ?ata????s? t?p?? commit st? log 2.
G???e st? d?s?? ??e? t?? ?ata????se?? t?? log
??? t? lastLSN t?? d?s?????a? flushedLSN ??
lastLSN (WAL) 3. ????? t?? Commit 4. G???e µ?a
?ata????s? t?p?? end st? log
28
ARIEL A????s? ??s?????a?
  • ??????, a? ?e???s??µe ?t? de s?µßa????? ap?t???e?

S????S UNDO (a?a??es?) t?? e???af?? (updates)
29
ARIEL A????s? ??s?????a?
?a????µe t? log t?? d?s?????a? a??p?da 1.
G??f??µe st? log µ?a ?ata????s? t?p?? abort 2.
?a?????µe t? lastLSN t?? d?s?????a? ap? t??
???a?a ??s??????? 3. ?????????µe t?? a??s?da t??
?ata????se?? st? log ß?se? t?? ped??? prevLSN
30
ARIEL A????s? ??s?????a?
  • G?a ?a t? e?te??s??µe t?? a?a??es? p??pe? ?a
    ????µe ??e?d? sta ded?µ??a
  • ???? ?a ??????µe t?? p??????µe?? t?µ? se µ?a
    se??da, ???f??µe st? log µ?a ?ata????s? t?p?? CLR
  • ? ?ata????s? CLR ??e? ??a ped?? undonextLSN
    ep?µe?? LSN p??? a?a??es?
  • ??a ?ata????s? t?p?? CLR de ??e???eta? ?a
    a?a??e?e? (a??? µp??e? ?a ??e?aste? ?a
    epa?a??f?e?)
  • St? t????, ????e µ?a ?ata????s? t?p?? end

31
ARIEL S?µe?a ???????
?e???d???, t? S??? d?µ?????e? ??a s?µe?? e??????
(checkpoint), µe s??p? t? µe??s? t?? ?????? p??
??e???eta? ??a a???aµ?? st?? pe??pt?s? ap?t???a?
  • G??fe? t?? ???a?a ??s??????? ?a? t?? ???a?a
    ???p?p???µ???? Se??d?? st? log
  • G??fe? st? log
  • µ?a e???af? begin_checkpoint p?? d????e? p?te
    ????se t? chkpt.
  • µ?a e???af? end_checkpoint p?? d????e? p?te
    t??e??se t? chkpt

32
ARIEL S?µe?a ???????
  • ?saf?? (fuzzy)
  • ?? d?s?????e? e?a????????? ?a e?te????ta?. ??
    p??a?e? e??a? a???ße?? ?? p??? t?
    begin_checkpoint
  • ?e? ???f??ta? t??p?p???µ??e? se??de? st? d?s??

?? LSN t?? e???af?? t?? chkpt ???feta? se asfa??
???? (master record)
33
ARIEL H Ge???? ?????a
LOG
RAM
DB
LogRecords
???a?a? ??s??????? lastLSN status ???a?a?
???p?p???µ???? Se??d?? recLSN flushedLSN
Se??de? ?ed?µ???? se ???e se??da pageLSN
master record
34
ARIEL ?a??de??µa
LSN LOG
begin_checkpoint end_checkpoint update T1
writes P5 update T2 writes P3 T1 abort CLR Undo
T1 LSN 10 T1 End update T3 writes P1 update T2
writes P5 CRASH, RESTART
00 05 10 20 30 40
45 50 60
prevLSNs
???a?a? ??s??????? lastLSN status ???a?a?
???p?p???µ???? Se??d?? recLSN flushedLSN
35
ARIEL ????aµ?? ap? ?p?t???a
??e?? F?se?? ?????S? -- a?a?atas?e?? t?? p??????
t?? s?st?µat?? p??e? se??de? e??a?
t??p?p???µ??e?, p??a e??a? ? ?at?stas? t??
d?s??????? ????????? (REDO) -- epa?????? ????
t?? d?s??????? ????OS? (UNDO) -- a?a??es? t??
d?s??????? p?? de? ?ta? ep?????µ??e?
36
ARIEL ? F?s? t?? ?????s??
?????S? -- a?a?atas?e?? t?? p?????? t??
s?st?µat?? (??????S ??S?????O? ??????S
????????????O? S????O?) ???s?µ?p????ta? t?
te?e?ta?? ????????µ??? checkpoint p??a e??a? ?
?at?stas? t?? d?s??????? ap? t?te p??e? se??de?
e??a? t??p?p???µ??e? ap? t?te
37
ARIEL ? F?s? t?? ?????s??
  • ???? ap? t? te?e?ta?? checkpoint
  • ???es? t?? µe ???s? t?? master record
  • ???s???µe t? a?t?st???? begin_chkpoint

38
ARIEL ? F?s? t?? ?????s??
??aß????µe t? log forward ?e?????ta? ap? t?
begin_chkpoint. ?? ß???µe ?ata????s? t?p?? end
sß????µe t? d?s?????a ap? t?? ???a?a
??s??????? ???? t?p? e?sa???? d?s?????a? µe
lastLSN LSN, a??a?? ?at?stas?? a? commit update
(e???af?) ?? ? P de? e??a? st?? ???a?a
???p?p???µ???? Se??d?? e?sa???? t?? P st??
p??a?a µe recLSNLSN.
39
ARIEL ? F?s? t?? ?????s??
?p?t??esµa ?? p??a?e? ?p?? ?ta? t? st??µ? p??
????aµe t? te?e?ta?? log st? d?s?? (te?e?ta?a
ep?????s? d?s?????a?)
40
ARIEL ????aµ?? ap? ?p?t???a
??e?? F?se?? ?????S? -- ????????? (REDO) --
epa?????? ???? t?? d?s??????? ????OS? (UNDO) --
a?a??es? t?? d?s??????? p?? de? ?ta? ep?????µ??e?
41
ARIEL ? F?s? t?? ?pa???????
  • ?pa?a?aµß????µe t? log ?ste ?a ft?s??µe st??
    ?at?stas? t? st??µ? t?? ap?t???a?
  • ?pa?a?aµß????µe t?? e???af?? a??µa ?a? t??
    d?s??????? p?? a???????a? (aborted)

???????µe st? log forward ?e?????ta? ap? t?
µ????te?? recLSN st?? ???a?a ???p?p???µ????
Se??d??
42
ARIEL ? F?s? t?? ?pa???????
  • G?a ???e ?ata????s? t?p?? update ? CLR, epa???aße
    t?? p???? e?t?? a?
  • ? se??da de? e??a? st?? ???a?a ???p?p???µ????
    Se??d??
  • ? se??da e??a? st?? ???a?a ???p?p???µ????
    Se??d?? a??? recLSN LSN
  • pageLSN (st? d?s??) ? LSN
  • S?µe??s? de ????????µe p??e? se??de? ?????
    ??afte? st? d?s??

43
ARIEL ? F?s? t?? ?pa???????
  • G?a ?a epa?a??ße?? µ?a p????
  • epa?e?t??es?
  • ??se pageLSN LSN
  • de ??e???eta? log

44
ARIEL ????aµ?? ap? ?p?t???a
??e?? F?se?? ?????S? -- ????????? (REDO) --
epa?????? ???? t?? d?s??????? ????OS? (UNDO) --
a?a??es? t?? d?s??????? p?? de? ?ta? ep?????µ??e?
45
ARIEL ? F?s? t?? ??a??es??
?atas?e?? ??sta? ToUndo lastLSN t?? ? ?
d?s?????a p??? a?a??es? d?s?????e? p???
a?a??es? d?s?????e? e?e???? ?at? t?? ap?t???a
46
ARIEL ? F?s? t?? ??a??es??
  • Repeat
  • ?p??e?e t? µe?a??te?? LSN st?? ??sta ToUndo.
  • If t? LSN e??a? t?p?? CLR ?a? undonextLSN NULL
  • ????e µ?a ?ata????s? t?p?? end ??a t? d?s?????a.
  • If t? LSN e??a? t?p?? CLR ?a? undonextLSN ! NULL
  • ???s?ese t? undonextLSN st?? ??sta ToUndo
  • Else if t? LSN e??a? t?p?? update.
  • Undo t? update,
  • G???e µ?a ?ata????s? t?p?? CLR,
  • ???s?ese t? prevLSN st?? ??sta ToUndo.
  • Until ToUndo is empty.

47
ARIEL ????aµ?? ap? ?p?t???a
?a???te?? ?ata????s? log d?s?????a? e?e???? ?at?
t?? ap?t???a
  • ????se ap? ??a s?µe?? e?????? (p?? ß??s?eta? µ?s?
    t?? master record).
  • ??e?? F?se??.
  • ???es? p??e? d?s?????e? µet? t? s?µe?? e??????
    ep????????a?, p??e? a???????a? (?????S?).
  • REDO ??e? t?? d?s?????e?.
  • (repeat history)
  • UNDO t? ap?t??esµa t?? ap?t???µ???? d?s???????

U
?????te?? recLSN st?? ???a?a ???p?p???µ????
Se??d?? µet? t?? ?????s?
R
A
?e?e?ta?? chkpt
????????
48
ARIEL ?a??de??µa
LSN LOG
begin_checkpoint end_checkpoint update T1
writes P5 update T2 writes P3 T1 abort CLR Undo
T1 LSN 10 T1 End update T3 writes P1 update T2
writes P5 CRASH, RESTART
00 05 10 20 30 40
45 50 60
prevLSNs
???a?a? ??s??????? lastLSN status ???a?a?
???p?p???µ???? Se??d?? recLSN flushedLSN
ToUndo
49
ARIEL ?a??de??µa
LSN LOG
begin_checkpoint, end_checkpoint update T1
writes P5 update T2 writes P3 T1 abort CLR Undo
T1 LSN 10, T1 End update T3 writes P1 update T2
writes P5 CRASH, RESTART CLR Undo T2 LSN 60 CLR
Undo T3 LSN 50, T3 end CRASH, RESTART CLR Undo
T2 LSN 20, T2 end
00,05 10 20 30 40,45 50
60 70 80,85 90
undonextLSN
???a?a? ??s??????? lastLSN status ???a?a?
???p?p???µ???? Se??d?? recLSN flushedLSN
ToUndo
50
?e?????? ????aµ???
  • ?fed???? a?t???afa
  • S???d?? Se??d?p???s?
Write a Comment
User Comments (0)
About PowerShow.com